Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
joaomoreno committed Mar 12, 2018
2 parents 8548bcb + 3f731d3 commit ee02bc3
Show file tree
Hide file tree
Showing 18 changed files with 634 additions and 135 deletions.
4 changes: 2 additions & 2 deletions extensions/typescript/src/features/taskProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ class TscTaskProvider implements vscode.TaskProvider {
project.workspaceFolder || vscode.TaskScope.Workspace,
localize('buildTscLabel', 'build - {0}', label),
'tsc',
new vscode.ShellExecution(`${command} -p "${project.path}"`),
new vscode.ShellExecution(command, ['-p', project.path]),
'$tsc');
buildTask.group = vscode.TaskGroup.Build;
buildTask.isBackground = false;
Expand All @@ -200,7 +200,7 @@ class TscTaskProvider implements vscode.TaskProvider {
project.workspaceFolder || vscode.TaskScope.Workspace,
localize('buildAndWatchTscLabel', 'watch - {0}', label),
'tsc',
new vscode.ShellExecution(`${command} --watch -p "${project.path}"`),
new vscode.ShellExecution(command, ['--watch', '-p', project.path]),
'$tsc-watch');
watchTask.group = vscode.TaskGroup.Build;
watchTask.isBackground = true;
Expand Down
41 changes: 15 additions & 26 deletions src/vs/editor/contrib/gotoError/gotoError.ts
Original file line number Diff line number Diff line change
Expand Up @@ -109,40 +109,33 @@ class MarkerModel {
}
}

private move(fwd: boolean): void {
public move(fwd: boolean, circle: boolean): boolean {
if (!this.canNavigate()) {
this._onCurrentMarkerChanged.fire(undefined);
return;
return false;
}

let old = this._nextIdx;
if (this._nextIdx === -1) {
this._initIdx(fwd);

} else if (fwd) {
this._nextIdx += 1;
if (this._nextIdx >= this._markers.length) {
this._nextIdx = 0;
}
this._nextIdx = (this._nextIdx + 1) % this._markers.length;
} else {
this._nextIdx -= 1;
if (this._nextIdx < 0) {
this._nextIdx = this._markers.length - 1;
}
this._nextIdx = (this._nextIdx - 1 + this._markers.length) % this._markers.length;
}
const marker = this._markers[this._nextIdx];
this._onCurrentMarkerChanged.fire(marker);
}

public canNavigate(): boolean {
return this._markers.length > 0;
}
if (circle || old === -1 || fwd && old < this._nextIdx || !fwd && old > this._nextIdx) {
const marker = this._markers[this._nextIdx];
this._onCurrentMarkerChanged.fire(marker);
return false;
}

public next(): void {
this.move(true);
// we circled, didn't send an event, and return `true`
return true;
}

public previous(): void {
this.move(false);
public canNavigate(): boolean {
return this._markers.length > 0;
}

public findMarkerAtPosition(pos: Position): IMarker {
Expand Down Expand Up @@ -183,11 +176,7 @@ class MarkerNavigationAction extends EditorAction {
}

const model = controller.getOrCreateModel();
if (this._isNext) {
model.next();
} else {
model.previous();
}
model.move(this._isNext, true);
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/vs/editor/contrib/rename/rename.ts
Original file line number Diff line number Diff line change
Expand Up @@ -184,9 +184,9 @@ class RenameController implements IEditorContribution {

}, err => {
this._renameInputVisible.reset();
this.editor.focus();

if (!isPromiseCanceledError(err)) {
this.editor.focus();
return TPromise.wrapError(err);
}
return undefined;
Expand Down
4 changes: 2 additions & 2 deletions src/vs/platform/actions/browser/menuItemActionItem.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import { IdGenerator } from 'vs/base/common/idGenerator';
import { createCSSRule } from 'vs/base/browser/dom';
import URI from 'vs/base/common/uri';
import { INotificationService } from 'vs/platform/notification/common/notification';
import { isWindows } from 'vs/base/common/platform';
import { isWindows, isLinux } from 'vs/base/common/platform';

// The alternative key on all platforms is alt. On windows we also support shift as an alternative key #44136
class AlternativeKeyEmitter extends Emitter<boolean> {
Expand All @@ -31,7 +31,7 @@ class AlternativeKeyEmitter extends Emitter<boolean> {
super();

this._subscriptions.push(domEvent(document.body, 'keydown')(e => {
this.isPressed = e.altKey || (isWindows && e.shiftKey);
this.isPressed = e.altKey || ((isWindows || isLinux) && e.shiftKey);
}));
this._subscriptions.push(domEvent(document.body, 'keyup')(e => this.isPressed = false));
this._subscriptions.push(domEvent(document.body, 'mouseleave')(e => this.isPressed = false));
Expand Down
108 changes: 106 additions & 2 deletions src/vs/vscode.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4332,6 +4332,38 @@ declare module 'vscode' {
options?: ProcessExecutionOptions;
}

/**
* The shell quoting options.
*/
export interface ShellQuotingOptions {

/**
* The character used to do character escaping. If a string is provided only spaces
* are escaped. If a `{ escapeChar, charsToEscape }` literal is provide all characters
* in `charsToEscape` are escaped using the `escapeChar`.
*/
escape?: string | {
/**
* The escape character.
*/
escapeChar: string;
/**
* The characters to escape.
*/
charsToEscape: string;
};

/**
* The character used for strong quoting. The string's length must be 1.
*/
strong?: string;

/**
* The character used for weak quoting. The string's length must be 1.
*/
weak?: string;
}

/**
* Options for a shell execution
*/
Expand All @@ -4346,6 +4378,11 @@ declare module 'vscode' {
*/
shellArgs?: string[];

/**
* The shell quotes supported by this shell.
*/
shellQuoting?: ShellQuotingOptions;

/**
* The current working directory of the executed shell.
* If omitted the tools current workspace root is used.
Expand All @@ -4360,21 +4397,88 @@ declare module 'vscode' {
env?: { [key: string]: string };
}

/**
* Defines how an argument should be quoted if it contains
* spaces or unsuppoerted characters.
*/
export enum ShellQuoting {

/**
* Character escaping should be used. This for example
* uses \ on bash and ` on PowerShell.
*/
Escape = 1,

/**
* Strong string quoting should be used. This for example
* uses " for Windows cmd and ' for bash and PowerShell.
* Strong quoting treats arguments as literal strings.
* Under PowerShell echo 'The value is $(2 * 3)' will
* print `The value is $(2 * 3)`
*/
Strong = 2,

/**
* Weak string quoting should be used. This for example
* uses " for Windows cmd, bash and PowerShell. Weak quoting
* still performs some kind of evaluation inside the quoted
* string. Under PowerShell echo "The value is $(2 * 3)"
* will print `The value is 6`
*/
Weak = 3
}

/**
* A string that will be quoted depending on the used shell.
*/
export interface ShellQuotedString {
/**
* The actual string value.
*/
value: string;

/**
* The quoting style to use.
*/
quoting: ShellQuoting;
}

export class ShellExecution {
/**
* Creates a process execution.
* Creates a shell execution with a full command line.
*
* @param commandLine The command line to execute.
* @param options Optional options for the started the shell.
*/
constructor(commandLine: string, options?: ShellExecutionOptions);

/**
* The shell command line
* Creates a shell execution with a command and arguments. For the real execution VS Code will
* construct a command line from the command and the arguments. This is subject to interpretation
* especially when it comes to quoting. If full control over the command line is needed please
* use the constructor that creates a `ShellExecution` with the full command line.
*
* @param command The command to execute.
* @param args The command arguments.
* @param options Optional options for the started the shell.
*/
constructor(command: string | ShellQuotedString, args: (string | ShellQuotedString)[], options?: ShellExecutionOptions);

/**
* The shell command line. Is `undefined` if created with a command and arguments.
*/
commandLine: string;

/**
* The shell command. Is `undefined` if created with a full command line.
*/
command: string | ShellQuotedString;

/**
* The shell args. Is `undefined` if created with a full command line.
*/
args: (string | ShellQuotedString)[];

/**
* The shell options used when the command line is executed in a shell.
* Defaults to undefined.
Expand Down
1 change: 1 addition & 0 deletions src/vs/workbench/api/node/extHost.api.impl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -638,6 +638,7 @@ export function createApiFactory(
TaskGroup: extHostTypes.TaskGroup,
ProcessExecution: extHostTypes.ProcessExecution,
ShellExecution: extHostTypes.ShellExecution,
ShellQuoting: extHostTypes.ShellQuoting,
TaskScope: extHostTypes.TaskScope,
Task: extHostTypes.Task,
ConfigurationTarget: extHostTypes.ConfigurationTarget,
Expand Down
65 changes: 52 additions & 13 deletions src/vs/workbench/api/node/extHostTask.ts
Original file line number Diff line number Diff line change
Expand Up @@ -278,20 +278,43 @@ namespace CommandOptions {
}
}

namespace ShellQuoteOptions {
export function from(value: vscode.ShellQuotingOptions): TaskSystem.ShellQuotingOptions {
if (value === void 0 || value === null) {
return undefined;
}
return {
escape: value.escape,
strong: value.strong,
weak: value.strong
};
}
}

namespace ShellConfiguration {
export function from(value: { executable?: string, shellArgs?: string[] }): TaskSystem.ShellConfiguration {
export function from(value: { executable?: string, shellArgs?: string[], quotes?: vscode.ShellQuotingOptions }): TaskSystem.ShellConfiguration {
if (value === void 0 || value === null || !value.executable) {
return undefined;
}

let result: TaskSystem.ShellConfiguration = {
executable: value.executable,
args: Strings.from(value.shellArgs)
args: Strings.from(value.shellArgs),
quoting: ShellQuoteOptions.from(value.quotes)
};
return result;
}
}

namespace ShellString {
export function from(value: (string | vscode.ShellQuotedString)[]): TaskSystem.CommandString[] {
if (value === void 0 || value === null) {
return undefined;
}
return value.slice(0);
}
}

namespace Tasks {

export function from(tasks: vscode.Task[], rootFolder: vscode.WorkspaceFolder, extension: IExtensionDescription): TaskSystem.ContributedTask[] {
Expand Down Expand Up @@ -396,18 +419,34 @@ namespace Tasks {
}

function getShellCommand(value: vscode.ShellExecution): TaskSystem.CommandConfiguration {
if (typeof value.commandLine !== 'string') {
return undefined;
}
let result: TaskSystem.CommandConfiguration = {
name: value.commandLine,
runtime: TaskSystem.RuntimeType.Shell,
presentation: undefined
};
if (value.options) {
result.options = CommandOptions.from(value.options);
if (value.args) {
if (typeof value.command !== 'string' && typeof value.command.value !== 'string') {
return undefined;
}
let result: TaskSystem.CommandConfiguration = {
name: value.command,
args: ShellString.from(value.args),
runtime: TaskSystem.RuntimeType.Shell,
presentation: undefined
};
if (value.options) {
result.options = CommandOptions.from(value.options);
}
return result;
} else {
if (typeof value.commandLine !== 'string') {
return undefined;
}
let result: TaskSystem.CommandConfiguration = {
name: value.commandLine,
runtime: TaskSystem.RuntimeType.Shell,
presentation: undefined
};
if (value.options) {
result.options = CommandOptions.from(value.options);
}
return result;
}
return result;
}
}

Expand Down
Loading

0 comments on commit ee02bc3

Please sign in to comment.