提交 2470fe43 编写于 作者: K kieferrm

Merge branch 'master' of github.com:Microsoft/vscode

......@@ -7,9 +7,11 @@
import nls = require('vs/nls');
import * as Paths from 'vs/base/common/paths';
import * as emmet from 'emmet';
import {fileExists} from 'vs/base/node/pfs';
import {createPath} from 'vs/workbench/parts/emmet/node/fileAccessor';
import fs = require('fs');
import {dirname, join, normalize, isValidBasename} from 'vs/base/common/paths';
import {EmmetEditorAction} from 'vs/workbench/parts/emmet/node/emmetActions';
import {Action} from 'vs/base/common/actions';
......@@ -19,6 +21,8 @@ import {IConfigurationService} from 'vs/platform/configuration/common/configurat
import {IMessageService, Severity} from 'vs/platform/message/common/message';
import {IQuickOpenService, IInputOptions} from 'vs/workbench/services/quickopen/common/quickOpenService';
import {IWorkspaceContextService} from 'vs/workbench/services/workspace/common/contextService';
import {IFileService} from 'vs/platform/files/common/files';
class EncodeDecodeDataUrlAction extends EmmetEditorAction {
......@@ -29,11 +33,21 @@ class EncodeDecodeDataUrlAction extends EmmetEditorAction {
@IConfigurationService configurationService: IConfigurationService,
@IWorkspaceContextService private workspaceContext: IWorkspaceContextService,
@IQuickOpenService private quickOpenService: IQuickOpenService,
@IMessageService private messageService: IMessageService) {
@IMessageService private messageService: IMessageService,
@IFileService private fileService: IFileService) {
super(descriptor, editor, configurationService);
}
public runEmmetAction(_emmet) {
private createPath(parent: string, fileName: string): string {
// TO DO replace with IFileService
var stat = fs.statSync(parent);
if (stat && !stat.isDirectory()) {
parent = dirname(parent);
}
return join(parent, fileName);
};
public runEmmetAction(_emmet: typeof emmet) {
const currentLine = this.editorAccessor.getCurrentLine();
if (!this.isDataURI(currentLine)) {
this.encodeDecode(_emmet);
......@@ -58,7 +72,7 @@ class EncodeDecodeDataUrlAction extends EmmetEditorAction {
}
this.imageFilePath = path;
const fullpath = createPath(this.editorAccessor.getFilePath(), path);
const fullpath = this.createPath(this.editorAccessor.getFilePath(), path);
return fileExists(fullpath);
})
.then(status => {
......@@ -97,12 +111,12 @@ class EncodeDecodeDataUrlAction extends EmmetEditorAction {
// Validate all segments of path without absolute and empty segments
// Valid: `images/test.png`, `./test.png`, `../images/test.png`, `\images\test.png`
let isValidFilePath = true;
const filePathSegments = Paths.normalize(input).split('/').filter(segment => {
const filePathSegments = normalize(input).split('/').filter(segment => {
return segment.length !== 0 && segment !== '..';
});
for (let i = 0; i < filePathSegments.length; i++) {
if (!Paths.isValidBasename(filePathSegments[i])) {
if (!isValidBasename(filePathSegments[i])) {
isValidFilePath = false;
break;
}
......
......@@ -7,6 +7,7 @@
import nls = require('vs/nls');
import {EmmetEditorAction} from 'vs/workbench/parts/emmet/node/emmetActions';
import * as emmet from 'emmet';
import {CommonEditorRegistry, EditorActionDescriptor} from 'vs/editor/common/editorCommonExtensions';
import {IEditorActionDescriptorData, ICommonCodeEditor} from 'vs/editor/common/editorCommon';
......@@ -23,7 +24,7 @@ class UpdateTagAction extends EmmetEditorAction {
super(descriptor, editor, configurationService);
}
public runEmmetAction(_emmet) {
public runEmmetAction(_emmet: typeof emmet) {
let options: IInputOptions = {
prompt: nls.localize('enterTag', 'Enter Tag'),
placeHolder: nls.localize('tag', 'Tag')
......@@ -33,7 +34,7 @@ class UpdateTagAction extends EmmetEditorAction {
});
}
private wrapAbbreviation(_emmet: any, tag) {
private wrapAbbreviation(_emmet: typeof emmet, tag) {
if (tag && !_emmet.run('update_tag', this.editorAccessor, tag)) {
this.noExpansionOccurred();
}
......
......@@ -7,6 +7,7 @@
import nls = require('vs/nls');
import {EmmetEditorAction} from 'vs/workbench/parts/emmet/node/emmetActions';
import * as emmet from 'emmet';
import {CommonEditorRegistry, EditorActionDescriptor} from 'vs/editor/common/editorCommonExtensions';
import {IEditorActionDescriptorData, ICommonCodeEditor} from 'vs/editor/common/editorCommon';
......@@ -23,7 +24,7 @@ class WrapWithAbbreviationAction extends EmmetEditorAction {
super(descriptor, editor, configurationService);
}
public runEmmetAction(_emmet) {
public runEmmetAction(_emmet: typeof emmet) {
let options: IInputOptions = {
prompt: nls.localize('enterAbbreviation', "Enter Abbreviation"),
placeHolder: nls.localize('abbreviation', "Abbreviation")
......@@ -33,7 +34,7 @@ class WrapWithAbbreviationAction extends EmmetEditorAction {
});
}
private wrapAbbreviation(_emmet: any, abbreviation) {
private wrapAbbreviation(_emmet: typeof emmet, abbreviation) {
if (abbreviation && !_emmet.run('wrap_with_abbreviation', this.editorAccessor, abbreviation)) {
this.noExpansionOccurred();
}
......
......@@ -10,6 +10,16 @@ declare module 'emmet' {
end: number;
}
export interface Preferences {
set(key:string, value: string);
define(key:string, value: string);
remove(key:string);
}
export interface Profiles {
reset();
}
export interface Editor {
/**
* Returns character indexes of selected text: object with <code>start</code>
......@@ -134,7 +144,11 @@ declare module 'emmet' {
* @param {IEmmetEditor} editor Editor instance
* @return {Boolean} Returns true if action was performed successfully
*/
export function run(action: string, editor: Editor): boolean;
export function run(action: string, editor: Editor, arg?: string): boolean;
export var preferences: Preferences;
export var profile: Profiles;
export function file(fileAccessor:any): void;
export function loadProfiles(profiles: any);
}
......@@ -11,7 +11,6 @@ import {EditorAction} from 'vs/editor/common/editorAction';
import {Behaviour} from 'vs/editor/common/editorActionEnablement';
import {EditorAccessor} from 'vs/workbench/parts/emmet/node/editorAccessor';
import * as fileAccessor from 'vs/workbench/parts/emmet/node/fileAccessor';
import {IConfigurationService} from 'vs/platform/configuration/common/configuration';
import * as emmet from 'emmet';
......@@ -34,7 +33,7 @@ export abstract class EmmetEditorAction extends EditorAction {
this.configurationService = configurationService;
}
private updateEmmetPreferences(_emmet: any) {
private updateEmmetPreferences(_emmet: typeof emmet) {
let preferences = this.configurationService.getConfiguration<IEmmetConfiguration>().emmet.preferences;
for (let key in preferences) {
try {
......@@ -50,7 +49,7 @@ export abstract class EmmetEditorAction extends EditorAction {
}
}
private resetEmmetPreferences(_emmet: any) {
private resetEmmetPreferences(_emmet: typeof emmet) {
let preferences = this.configurationService.getConfiguration<IEmmetConfiguration>().emmet.preferences;
for (let key in preferences) {
try {
......@@ -60,7 +59,7 @@ export abstract class EmmetEditorAction extends EditorAction {
}
}
abstract runEmmetAction(_emmet: any);
abstract runEmmetAction(_emmet: typeof emmet);
protected noExpansionOccurred() {
// default do nothing
......@@ -73,7 +72,6 @@ export abstract class EmmetEditorAction extends EditorAction {
}
return this._withEmmet().then((_emmet) => {
_emmet.file(fileAccessor);
this._withEmmetPreferences(_emmet, () => {
this.editorAccessor.onBeforeEmmetAction();
this.runEmmetAction(_emmet);
......@@ -110,7 +108,7 @@ export class BasicEmmetEditorAction extends EmmetEditorAction {
this.emmetActionName = actionName;
}
public runEmmetAction(_emmet) {
public runEmmetAction(_emmet: typeof emmet) {
if (!_emmet.run(this.emmetActionName, this.editorAccessor)) {
this.noExpansionOccurred();
}
......
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
'use strict';
import fs = require('fs');
import {dirname, join} from 'vs/base/common/paths';
import {mkdirp, writeFile} from 'vs/base/node/pfs';
export function createPath(parent: string, fileName: string): string {
var stat = fs.statSync(parent);
if (stat && !stat.isDirectory()) {
parent = dirname(parent);
}
return join(parent, fileName);
};
export function save(file: string, content: string): any {
mkdirp(dirname(file)).then(() => {
return writeFile(file, content, 'ascii');
}, err => {
//
});
}
......@@ -55,14 +55,6 @@ configurationRegistry.registerConfiguration({
'type': 'string',
'default': TERMINAL_DEFAULT_SHELL_WINDOWS
},
'terminal.integrated.shellArgs.windows': {
'description': nls.localize('terminal.integrated.shellArgs.windows', "The command line arguments to use when on the Windows terminal."),
'type': 'array',
'items': {
'type': 'string'
},
'default': []
},
'terminal.integrated.fontFamily': {
'description': nls.localize('terminal.integrated.fontFamily', "Controls the font family of the terminal, this defaults to editor.fontFamily's value."),
'type': 'string'
......
......@@ -32,8 +32,7 @@ export interface ITerminalConfiguration {
},
shellArgs: {
linux: string[],
osx: string[],
windows: string[]
osx: string[]
},
fontFamily: string,
fontSize: number,
......
......@@ -150,7 +150,6 @@ export class TerminalConfigHelper {
};
if (this.platform === Platform.Windows) {
shell.executable = config.terminal.integrated.shell.windows;
shell.args = config.terminal.integrated.shellArgs.windows;
} else if (this.platform === Platform.Mac) {
shell.executable = config.terminal.integrated.shell.osx;
shell.args = config.terminal.integrated.shellArgs.osx;
......
......@@ -164,9 +164,6 @@ suite('Workbench - TerminalConfigHelper', () => {
integrated: {
shell: {
windows: 'foo'
},
shellArgs: {
windows: []
}
}
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册