diff --git a/extensions/css-language-features/server/src/pathCompletion.ts b/extensions/css-language-features/server/src/pathCompletion.ts index 4d988a52da9..aafed82b513 100644 --- a/extensions/css-language-features/server/src/pathCompletion.ts +++ b/extensions/css-language-features/server/src/pathCompletion.ts @@ -154,10 +154,10 @@ function pathToReplaceRange(valueBeforeCursor: string, fullValue: string, fullVa const valueAfterLastSlash = fullValue.slice(lastIndexOfSlash + 1); const startPos = shiftPosition(fullValueRange.end, -valueAfterLastSlash.length); // If whitespace exists, replace until it - const whiteSpaceIndex = valueAfterLastSlash.indexOf(' '); + const whitespaceIndex = valueAfterLastSlash.indexOf(' '); let endPos; - if (whiteSpaceIndex !== -1) { - endPos = shiftPosition(startPos, whiteSpaceIndex); + if (whitespaceIndex !== -1) { + endPos = shiftPosition(startPos, whitespaceIndex); } else { endPos = fullValueRange.end; } diff --git a/extensions/emmet/src/abbreviationActions.ts b/extensions/emmet/src/abbreviationActions.ts index e548023487f..26510e803cb 100644 --- a/extensions/emmet/src/abbreviationActions.ts +++ b/extensions/emmet/src/abbreviationActions.ts @@ -84,8 +84,8 @@ function doWrapping(individualLines: boolean, args: any) { const firstLineOfSelection = editor.document.lineAt(rangeToReplace.start).text.substr(rangeToReplace.start.character); const matches = firstLineOfSelection.match(/^(\s*)/); - const extraWhiteSpaceSelected = matches ? matches[1].length : 0; - rangeToReplace = new vscode.Range(rangeToReplace.start.line, rangeToReplace.start.character + extraWhiteSpaceSelected, rangeToReplace.end.line, rangeToReplace.end.character); + const extraWhitespaceSelected = matches ? matches[1].length : 0; + rangeToReplace = new vscode.Range(rangeToReplace.start.line, rangeToReplace.start.character + extraWhitespaceSelected, rangeToReplace.end.line, rangeToReplace.end.character); let textToWrapInPreview: string[]; let textToReplace = editor.document.getText(rangeToReplace); @@ -94,8 +94,8 @@ function doWrapping(individualLines: boolean, args: any) { } else { const wholeFirstLine = editor.document.lineAt(rangeToReplace.start).text; const otherMatches = wholeFirstLine.match(/^(\s*)/); - const preceedingWhiteSpace = otherMatches ? otherMatches[1] : ''; - textToWrapInPreview = rangeToReplace.isSingleLine ? [textToReplace] : ['\n\t' + textToReplace.split('\n' + preceedingWhiteSpace).join('\n\t') + '\n']; + const preceedingWhitespace = otherMatches ? otherMatches[1] : ''; + textToWrapInPreview = rangeToReplace.isSingleLine ? [textToReplace] : ['\n\t' + textToReplace.split('\n' + preceedingWhitespace).join('\n\t') + '\n']; } textToWrapInPreview = textToWrapInPreview.map(e => e.replace(/(\$\d)/g, '\\$1')); diff --git a/extensions/html-language-features/server/src/modes/pathCompletion.ts b/extensions/html-language-features/server/src/modes/pathCompletion.ts index 7451fee1d93..b7d7c1e7220 100644 --- a/extensions/html-language-features/server/src/modes/pathCompletion.ts +++ b/extensions/html-language-features/server/src/modes/pathCompletion.ts @@ -108,11 +108,12 @@ function pathToSuggestion(p: string, valueBeforeCursor: string, fullValue: strin // Find the last slash before cursor, and calculate the start of replace range from there const valueAfterLastSlash = fullValue.slice(lastIndexOfSlash + 1); const startPos = shiftPosition(range.end, -1 - valueAfterLastSlash.length); - // If whitespace exists, replace until it - const whiteSpaceIndex = valueAfterLastSlash.indexOf(' '); + + // If whitespace exists, replace until there is no more + const whitespaceIndex = valueAfterLastSlash.indexOf(' '); let endPos; - if (whiteSpaceIndex !== -1) { - endPos = shiftPosition(startPos, whiteSpaceIndex); + if (whitespaceIndex !== -1) { + endPos = shiftPosition(startPos, whitespaceIndex); } else { endPos = shiftPosition(range.end, -1); } diff --git a/extensions/vscode-api-tests/src/singlefolder-tests/workspace.tasks.test.ts b/extensions/vscode-api-tests/src/singlefolder-tests/workspace.tasks.test.ts new file mode 100644 index 00000000000..43470d24e19 --- /dev/null +++ b/extensions/vscode-api-tests/src/singlefolder-tests/workspace.tasks.test.ts @@ -0,0 +1,62 @@ +/*--------------------------------------------------------------------------------------------- + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for license information. + *--------------------------------------------------------------------------------------------*/ + +import * as assert from 'assert'; +import * as vscode from 'vscode'; + +suite.only('workspace-namespace', () => { + + suite('Tasks', () => { + + test('CustomExecution2 task should start and shutdown successfully', (done) => { + interface CustomTestingTaskDefinition extends vscode.TaskDefinition { + /** + * One of the task properties. This can be used to customize the task in the tasks.json + */ + customProp1: string; + } + const taskType: string = 'customTesting'; + const taskName = 'First custom task'; + const reg1 = vscode.window.onDidOpenTerminal(term => { + reg1.dispose(); + const reg2 = term.onDidWriteData(e => { + reg2.dispose(); + assert.equal(e, 'testing\r\n'); + term.dispose(); + }); + }); + const taskProvider = vscode.tasks.registerTaskProvider(taskType, { + provideTasks: () => { + const result: vscode.Task[] = []; + const kind: CustomTestingTaskDefinition = { + type: taskType, + customProp1: 'testing task one' + }; + const writeEmitter = new vscode.EventEmitter(); + const execution = new vscode.CustomExecution2((): Thenable => { + return Promise.resolve({ + onDidWrite: writeEmitter.event, + start: () => { + writeEmitter.fire('testing\r\n'); + }, + shutdown: () => { + taskProvider.dispose(); + done(); + } + }); + }); + const task = new vscode.Task2(kind, vscode.TaskScope.Workspace, taskName, taskType, execution); + result.push(task); + return result; + }, + resolveTask(_task: vscode.Task): vscode.Task | undefined { + assert.fail('resolveTask should not trigger during the test'); + return undefined; + } + }); + vscode.commands.executeCommand('workbench.action.tasks.runTask', `${taskType}: ${taskName}`); + }); + }); +}); diff --git a/src/vs/base/browser/ui/list/listWidget.ts b/src/vs/base/browser/ui/list/listWidget.ts index 08728828e58..6b920ee1e7a 100644 --- a/src/vs/base/browser/ui/list/listWidget.ts +++ b/src/vs/base/browser/ui/list/listWidget.ts @@ -236,7 +236,7 @@ class KeyboardController implements IDisposable { private view: ListView, options: IListOptions ) { - const multipleSelectionSupport = !(options.multipleSelectionSupport === false); + const multipleSelectionSupport = options.multipleSelectionSupport !== false; this.openController = options.openController || DefaultOpenController; diff --git a/src/vs/base/browser/ui/list/rangeMap.ts b/src/vs/base/browser/ui/list/rangeMap.ts index 73c6b7419ed..1bf7217d0af 100644 --- a/src/vs/base/browser/ui/list/rangeMap.ts +++ b/src/vs/base/browser/ui/list/rangeMap.ts @@ -190,4 +190,4 @@ export class RangeMap { dispose() { this.groups = null!; // StrictNullOverride: nulling out ok in dispose } -} \ No newline at end of file +} diff --git a/src/vs/base/common/glob.ts b/src/vs/base/common/glob.ts index 6746c06c9be..78fc5e97ce1 100644 --- a/src/vs/base/common/glob.ts +++ b/src/vs/base/common/glob.ts @@ -334,7 +334,6 @@ function wrapRelativePattern(parsedPattern: ParsedStringPattern, arg2: string | if (!extpath.isEqualOrParent(path, arg2.base)) { return null; } - return parsedPattern(paths.relative(arg2.base, path), basename); }; } diff --git a/src/vs/base/common/json.ts b/src/vs/base/common/json.ts index b3a62ede9ff..da0535be422 100644 --- a/src/vs/base/common/json.ts +++ b/src/vs/base/common/json.ts @@ -374,12 +374,12 @@ export function createScanner(text: string, ignoreTrivia: boolean = false): JSON let code = text.charCodeAt(pos); // trivia: whitespace - if (isWhiteSpace(code)) { + if (isWhitespace(code)) { do { pos++; value += String.fromCharCode(code); code = text.charCodeAt(pos); - } while (isWhiteSpace(code)); + } while (isWhitespace(code)); return token = SyntaxKind.Trivia; } @@ -517,7 +517,7 @@ export function createScanner(text: string, ignoreTrivia: boolean = false): JSON } function isUnknownContentCharacter(code: CharacterCodes) { - if (isWhiteSpace(code) || isLineBreak(code)) { + if (isWhitespace(code) || isLineBreak(code)) { return false; } switch (code) { @@ -555,7 +555,7 @@ export function createScanner(text: string, ignoreTrivia: boolean = false): JSON }; } -function isWhiteSpace(ch: number): boolean { +function isWhitespace(ch: number): boolean { return ch === CharacterCodes.space || ch === CharacterCodes.tab || ch === CharacterCodes.verticalTab || ch === CharacterCodes.formFeed || ch === CharacterCodes.nonBreakingSpace || ch === CharacterCodes.ogham || ch >= CharacterCodes.enQuad && ch <= CharacterCodes.zeroWidthSpace || ch === CharacterCodes.narrowNoBreakSpace || ch === CharacterCodes.mathematicalSpace || ch === CharacterCodes.ideographicSpace || ch === CharacterCodes.byteOrderMark; diff --git a/src/vs/editor/common/config/commonEditorConfig.ts b/src/vs/editor/common/config/commonEditorConfig.ts index e9fcfe8030a..889384a1748 100644 --- a/src/vs/editor/common/config/commonEditorConfig.ts +++ b/src/vs/editor/common/config/commonEditorConfig.ts @@ -904,7 +904,7 @@ const editorConfiguration: IConfigurationNode = { 'enum': ['none', 'boundary', 'selection', 'all'], 'enumDescriptions': [ '', - nls.localize('renderWhiteSpace.boundary', "Render whitespace characters except for single spaces between words."), + nls.localize('renderWhitespace.boundary', "Render whitespace characters except for single spaces between words."), nls.localize('renderWhitespace.selection', "Render whitespace characters only on selected text."), '' ], diff --git a/src/vs/editor/contrib/indentation/indentation.ts b/src/vs/editor/contrib/indentation/indentation.ts index 051a5378cf0..dc51d0faf45 100644 --- a/src/vs/editor/contrib/indentation/indentation.ts +++ b/src/vs/editor/contrib/indentation/indentation.ts @@ -589,13 +589,13 @@ export class AutoIndentOnPaste implements IEditorContribution { private shouldIgnoreLine(model: ITextModel, lineNumber: number): boolean { model.forceTokenization(lineNumber); - let nonWhiteSpaceColumn = model.getLineFirstNonWhitespaceColumn(lineNumber); - if (nonWhiteSpaceColumn === 0) { + let nonWhitespaceColumn = model.getLineFirstNonWhitespaceColumn(lineNumber); + if (nonWhitespaceColumn === 0) { return true; } let tokens = model.getLineTokens(lineNumber); if (tokens.getCount() > 0) { - let firstNonWhitespaceTokenIndex = tokens.findTokenIndexAtOffset(nonWhiteSpaceColumn); + let firstNonWhitespaceTokenIndex = tokens.findTokenIndexAtOffset(nonWhitespaceColumn); if (firstNonWhitespaceTokenIndex >= 0 && tokens.getStandardTokenType(firstNonWhitespaceTokenIndex) === StandardTokenType.Comment) { return true; } diff --git a/src/vs/editor/test/browser/controller/cursorMoveCommand.test.ts b/src/vs/editor/test/browser/controller/cursorMoveCommand.test.ts index 96bc4fc047d..92aedce2452 100644 --- a/src/vs/editor/test/browser/controller/cursorMoveCommand.test.ts +++ b/src/vs/editor/test/browser/controller/cursorMoveCommand.test.ts @@ -132,7 +132,7 @@ suite('Cursor move command test', () => { test('move to first non white space character of line from middle', () => { moveTo(thisCursor, 1, 8); - moveToLineFirstNonWhiteSpaceCharacter(thisCursor); + moveToLineFirstNonWhitespaceCharacter(thisCursor); cursorEqual(thisCursor, 1, 6); }); @@ -140,7 +140,7 @@ suite('Cursor move command test', () => { test('move to first non white space character of line from first non white space character', () => { moveTo(thisCursor, 1, 6); - moveToLineFirstNonWhiteSpaceCharacter(thisCursor); + moveToLineFirstNonWhitespaceCharacter(thisCursor); cursorEqual(thisCursor, 1, 6); }); @@ -148,7 +148,7 @@ suite('Cursor move command test', () => { test('move to first non white space character of line from first character', () => { moveTo(thisCursor, 1, 1); - moveToLineFirstNonWhiteSpaceCharacter(thisCursor); + moveToLineFirstNonWhitespaceCharacter(thisCursor); cursorEqual(thisCursor, 1, 6); }); @@ -180,7 +180,7 @@ suite('Cursor move command test', () => { test('move to last non white space character from middle', () => { moveTo(thisCursor, 1, 8); - moveToLineLastNonWhiteSpaceCharacter(thisCursor); + moveToLineLastNonWhitespaceCharacter(thisCursor); cursorEqual(thisCursor, 1, 19); }); @@ -188,7 +188,7 @@ suite('Cursor move command test', () => { test('move to last non white space character from last non white space character', () => { moveTo(thisCursor, 1, 19); - moveToLineLastNonWhiteSpaceCharacter(thisCursor); + moveToLineLastNonWhitespaceCharacter(thisCursor); cursorEqual(thisCursor, 1, 19); }); @@ -196,7 +196,7 @@ suite('Cursor move command test', () => { test('move to last non white space character from line end', () => { moveTo(thisCursor, 1, 21); - moveToLineLastNonWhiteSpaceCharacter(thisCursor); + moveToLineLastNonWhitespaceCharacter(thisCursor); cursorEqual(thisCursor, 1, 19); }); @@ -415,7 +415,7 @@ function moveToLineStart(cursor: Cursor) { move(cursor, { to: CursorMove.RawDirection.WrappedLineStart }); } -function moveToLineFirstNonWhiteSpaceCharacter(cursor: Cursor) { +function moveToLineFirstNonWhitespaceCharacter(cursor: Cursor) { move(cursor, { to: CursorMove.RawDirection.WrappedLineFirstNonWhitespaceCharacter }); } @@ -427,7 +427,7 @@ function moveToLineEnd(cursor: Cursor) { move(cursor, { to: CursorMove.RawDirection.WrappedLineEnd }); } -function moveToLineLastNonWhiteSpaceCharacter(cursor: Cursor) { +function moveToLineLastNonWhitespaceCharacter(cursor: Cursor) { move(cursor, { to: CursorMove.RawDirection.WrappedLineLastNonWhitespaceCharacter }); } diff --git a/src/vs/workbench/api/node/extHostTask.ts b/src/vs/workbench/api/node/extHostTask.ts index a1e82957b48..0e7f5f9dd7a 100644 --- a/src/vs/workbench/api/node/extHostTask.ts +++ b/src/vs/workbench/api/node/extHostTask.ts @@ -588,7 +588,7 @@ export class ExtHostTask implements ExtHostTaskShape { // Clone the custom execution to keep the original untouched. This is important for multiple runs of the same task. this._activeCustomExecutions2.set(execution.id, execution2); - this._terminalService.attachVirtualProcessToTerminal(terminalId, await execution2.callback()); + await this._terminalService.attachVirtualProcessToTerminal(terminalId, await execution2.callback()); } // Once a terminal is spun up for the custom execution task this event will be fired. diff --git a/src/vs/workbench/api/node/extHostTerminalService.ts b/src/vs/workbench/api/node/extHostTerminalService.ts index 8dea2f5f267..9b4a53b13e4 100644 --- a/src/vs/workbench/api/node/extHostTerminalService.ts +++ b/src/vs/workbench/api/node/extHostTerminalService.ts @@ -338,8 +338,8 @@ export class ExtHostTerminalService implements ExtHostTerminalServiceShape { return terminal; } - public attachVirtualProcessToTerminal(id: number, virtualProcess: vscode.TerminalVirtualProcess) { - const terminal = this._getTerminalById(id); + public async attachVirtualProcessToTerminal(id: number, virtualProcess: vscode.TerminalVirtualProcess): Promise { + const terminal = this._getTerminalByIdEventually(id); if (!terminal) { throw new Error(`Cannot resolve terminal with id ${id} for virtual process`); } @@ -621,6 +621,10 @@ export class ExtHostTerminalService implements ExtHostTerminalServiceShape { } public async $startVirtualProcess(id: number, initialDimensions: ITerminalDimensionsDto | undefined): Promise { + // Make sure the ExtHostTerminal exists so onDidOpenTerminal has fired before we call + // TerminalVirtualProcess.start + await this._getTerminalByIdEventually(id); + // Processes should be initialized here for normal virtual process terminals, however for // tasks they are responsible for attaching the virtual process to a terminal so this // function may be called before tasks is able to attach to the terminal.