Merge VS Code 1.31.1 (#4283)

This commit is contained in:
Matt Irvine
2019-03-15 13:09:45 -07:00
committed by GitHub
parent 7d31575149
commit 86bac90001
1716 changed files with 53308 additions and 48375 deletions

View File

@@ -43,7 +43,7 @@ class DocBlockCommentMode extends MockMode {
}
}
function testShiftCommand(lines: string[], languageIdentifier: LanguageIdentifier, useTabStops: boolean, selection: Selection, expectedLines: string[], expectedSelection: Selection): void {
function testShiftCommand(lines: string[], languageIdentifier: LanguageIdentifier | null, useTabStops: boolean, selection: Selection, expectedLines: string[], expectedSelection: Selection): void {
testCommand(lines, languageIdentifier, selection, (sel) => new ShiftCommand(sel, {
isUnshift: false,
tabSize: 4,
@@ -52,7 +52,7 @@ function testShiftCommand(lines: string[], languageIdentifier: LanguageIdentifie
}), expectedLines, expectedSelection);
}
function testUnshiftCommand(lines: string[], languageIdentifier: LanguageIdentifier, useTabStops: boolean, selection: Selection, expectedLines: string[], expectedSelection: Selection): void {
function testUnshiftCommand(lines: string[], languageIdentifier: LanguageIdentifier | null, useTabStops: boolean, selection: Selection, expectedLines: string[], expectedSelection: Selection): void {
testCommand(lines, languageIdentifier, selection, (sel) => new ShiftCommand(sel, {
isUnshift: true,
tabSize: 4,

View File

@@ -17,7 +17,7 @@ import { TestConfiguration } from 'vs/editor/test/common/mocks/testConfiguration
function testCommand(lines: string[], selections: Selection[], edits: IIdentifiedSingleEditOperation[], expectedLines: string[], expectedSelections: Selection[]): void {
withTestCodeEditor(lines, {}, (editor, cursor) => {
const model = editor.getModel();
const model = editor.getModel()!;
cursor.setSelections('tests', selections);
@@ -199,8 +199,8 @@ suite('SideEditing', () => {
function _runTest(selection: Selection, editRange: Range, editText: string, editForceMoveMarkers: boolean, expected: Selection, msg: string): void {
const model = TextModel.createFromString(LINES.join('\n'));
const config = new TestConfiguration(null);
const viewModel = new ViewModel(0, config, model, null);
const config = new TestConfiguration({});
const viewModel = new ViewModel(0, config, model, null!);
const cursor = new Cursor(config, model, viewModel);
cursor.setSelections('tests', [selection]);

View File

@@ -15,7 +15,7 @@ import { withEditorModel } from 'vs/editor/test/common/editorTestUtils';
/**
* Create single edit operation
*/
function createInsertDeleteSingleEditOp(text: string, positionLineNumber: number, positionColumn: number, selectionLineNumber: number = positionLineNumber, selectionColumn: number = positionColumn): IIdentifiedSingleEditOperation {
function createInsertDeleteSingleEditOp(text: string | null, positionLineNumber: number, positionColumn: number, selectionLineNumber: number = positionLineNumber, selectionColumn: number = positionColumn): IIdentifiedSingleEditOperation {
return {
range: new Range(selectionLineNumber, selectionColumn, positionLineNumber, positionColumn),
text: text
@@ -25,7 +25,7 @@ function createInsertDeleteSingleEditOp(text: string, positionLineNumber: number
/**
* Create single edit operation
*/
export function createSingleEditOp(text: string, positionLineNumber: number, positionColumn: number, selectionLineNumber: number = positionLineNumber, selectionColumn: number = positionColumn): IIdentifiedSingleEditOperation {
export function createSingleEditOp(text: string | null, positionLineNumber: number, positionColumn: number, selectionLineNumber: number = positionLineNumber, selectionColumn: number = positionColumn): IIdentifiedSingleEditOperation {
return {
range: new Range(selectionLineNumber, selectionColumn, positionLineNumber, positionColumn),
text: text

View File

@@ -151,8 +151,8 @@ suite('Editor Controller - Cursor', () => {
LINE5;
thisModel = createTextModel(text);
thisConfiguration = new TestConfiguration(null);
thisViewModel = new ViewModel(0, thisConfiguration, thisModel, null);
thisConfiguration = new TestConfiguration({});
thisViewModel = new ViewModel(0, thisConfiguration, thisModel, null!);
thisCursor = new Cursor(thisConfiguration, thisModel, thisViewModel);
});
@@ -735,8 +735,8 @@ suite('Editor Controller - Cursor', () => {
'var concat = require("gulp-concat");',
'var newer = require("gulp-newer");',
].join('\n'));
const config = new TestConfiguration(null);
const viewModel = new ViewModel(0, config, model, null);
const config = new TestConfiguration({});
const viewModel = new ViewModel(0, config, model, null!);
const cursor = new Cursor(config, model, viewModel);
moveTo(cursor, 1, 4, false);
@@ -774,8 +774,8 @@ suite('Editor Controller - Cursor', () => {
'<property id="SomeThing" key="SomeKey" value="000"/>',
'<property id="SomeThing" key="SomeKey" value="00X"/>',
].join('\n'));
const config = new TestConfiguration(null);
const viewModel = new ViewModel(0, config, model, null);
const config = new TestConfiguration({});
const viewModel = new ViewModel(0, config, model, null!);
const cursor = new Cursor(config, model, viewModel);
moveTo(cursor, 10, 10, false);
@@ -836,8 +836,8 @@ suite('Editor Controller - Cursor', () => {
'<property id="SomeThing" key="SomeKey" value="000"/>',
'<property id="SomeThing" key="SomeKey" value="00X"/>',
].join('\n'));
const config = new TestConfiguration(null);
const viewModel = new ViewModel(0, config, model, null);
const config = new TestConfiguration({});
const viewModel = new ViewModel(0, config, model, null!);
const cursor = new Cursor(config, model, viewModel);
moveTo(cursor, 10, 10, false);
@@ -885,8 +885,8 @@ suite('Editor Controller - Cursor', () => {
'var concat = require("gulp-concat");',
'var newer = require("gulp-newer");',
].join('\n'));
const config = new TestConfiguration(null);
const viewModel = new ViewModel(0, config, model, null);
const config = new TestConfiguration({});
const viewModel = new ViewModel(0, config, model, null!);
const cursor = new Cursor(config, model, viewModel);
moveTo(cursor, 1, 4, false);
@@ -1395,7 +1395,7 @@ suite('Editor Controller - Regression tests', () => {
'asdasd',
'qwerty'
], {}, (editor, cursor) => {
const model = editor.getModel();
const model = editor.getModel()!;
moveTo(cursor, 2, 1, false);
assertCursor(cursor, new Selection(2, 1, 2, 1));
@@ -1411,7 +1411,7 @@ suite('Editor Controller - Regression tests', () => {
'asdasd',
''
], {}, (editor, cursor) => {
const model = editor.getModel();
const model = editor.getModel()!;
moveTo(cursor, 2, 1, false);
assertCursor(cursor, new Selection(2, 1, 2, 1));
@@ -1981,7 +1981,7 @@ suite('Editor Controller - Regression tests', () => {
wordWrap: 'wordWrapColumn',
wordWrapColumn: 100
});
const viewModel = new ViewModel(0, config, model, null);
const viewModel = new ViewModel(0, config, model, null!);
const cursor = new Cursor(config, model, viewModel);
moveTo(cursor, 1, 43, false);
@@ -2050,9 +2050,9 @@ suite('Editor Controller - Regression tests', () => {
const tokenizationSupport: ITokenizationSupport = {
getInitialState: () => NULL_STATE,
tokenize: undefined,
tokenize: undefined!,
tokenize2: (line: string, state: IState): TokenizationResult2 => {
return new TokenizationResult2(null, state);
return new TokenizationResult2(null!, state);
}
};
@@ -2392,7 +2392,7 @@ suite('Editor Controller - Cursor Configuration', () => {
}
public computeCursorState(model: ITextModel, helper: ICursorStateComputerData): Selection {
return helper.getTrackedSelection(this._selectionId);
return helper.getTrackedSelection(this._selectionId!);
}
}
@@ -3626,7 +3626,7 @@ suite('Editor Controller - Indentation Rules', () => {
interface ICursorOpts {
text: string[];
languageIdentifier?: LanguageIdentifier;
languageIdentifier?: LanguageIdentifier | null;
modelOpts?: IRelaxedTextModelCreationOptions;
editorOpts?: IEditorOptions;
}
@@ -3634,8 +3634,8 @@ interface ICursorOpts {
function usingCursor(opts: ICursorOpts, callback: (model: TextModel, cursor: Cursor) => void): void {
let model = createTextModel(opts.text.join('\n'), opts.modelOpts, opts.languageIdentifier);
model.forceTokenization(model.getLineCount());
let config = new TestConfiguration(opts.editorOpts);
let viewModel = new ViewModel(0, config, model, null);
let config = new TestConfiguration(opts.editorOpts || {});
let viewModel = new ViewModel(0, config, model, null!);
let cursor = new Cursor(config, model, viewModel);
callback(model, cursor);

View File

@@ -31,8 +31,8 @@ suite('Cursor move command test', () => {
].join('\n');
thisModel = TextModel.createFromString(text);
thisConfiguration = new TestConfiguration(null);
thisViewModel = new ViewModel(0, thisConfiguration, thisModel, null);
thisConfiguration = new TestConfiguration({});
thisViewModel = new ViewModel(0, thisConfiguration, thisModel, null!);
thisCursor = new Cursor(thisConfiguration, thisModel, thisViewModel);
});

View File

@@ -123,7 +123,7 @@ suite('TextAreaState', () => {
textArea.dispose();
});
function testDeduceInput(prevState: TextAreaState, value: string, selectionStart: number, selectionEnd: number, couldBeEmojiInput: boolean, couldBeTypingAtOffset0: boolean, expected: string, expectedCharReplaceCnt: number): void {
function testDeduceInput(prevState: TextAreaState | null, value: string, selectionStart: number, selectionEnd: number, couldBeEmojiInput: boolean, couldBeTypingAtOffset0: boolean, expected: string, expectedCharReplaceCnt: number): void {
prevState = prevState || TextAreaState.EMPTY;
let textArea = new MockTextAreaWrapper();

View File

@@ -92,10 +92,10 @@ suite('Editor Core - Editor State', () => {
return {
getModel: (): ITextModel => <any>mappedModel,
getPosition: (): Position => position,
getSelection: (): Selection => selection,
getScrollLeft: (): number => scroll && scroll.left,
getScrollTop: (): number => scroll && scroll.top
getPosition: (): Position | undefined => position,
getSelection: (): Selection | undefined => selection,
getScrollLeft: (): number | undefined => scroll && scroll.left,
getScrollTop: (): number | undefined => scroll && scroll.top
} as ICodeEditor;
}

View File

@@ -15,7 +15,7 @@ import { IInstantiationService } from 'vs/platform/instantiation/common/instanti
export class TestCodeEditorService extends AbstractCodeEditorService {
public lastInput: IResourceInput;
public getActiveCodeEditor(): ICodeEditor | null { return null; }
public openCodeEditor(input: IResourceInput, source: ICodeEditor | null, sideBySide?: boolean): Thenable<ICodeEditor | null> {
public openCodeEditor(input: IResourceInput, source: ICodeEditor | null, sideBySide?: boolean): Promise<ICodeEditor | null> {
this.lastInput = input;
return Promise.resolve(null);
}
@@ -29,7 +29,7 @@ export class TestCommandService implements ICommandService {
private readonly _instantiationService: IInstantiationService;
private readonly _onWillExecuteCommand: Emitter<ICommandEvent> = new Emitter<ICommandEvent>();
private readonly _onWillExecuteCommand = new Emitter<ICommandEvent>();
public readonly onWillExecuteCommand: Event<ICommandEvent> = this._onWillExecuteCommand.event;
constructor(instantiationService: IInstantiationService) {
@@ -44,7 +44,7 @@ export class TestCommandService implements ICommandService {
try {
this._onWillExecuteCommand.fire({ commandId: id });
const result = this._instantiationService.invokeFunction.apply(this._instantiationService, [command.handler].concat(args));
const result = this._instantiationService.invokeFunction.apply(this._instantiationService, [command.handler, ...args]) as T;
return Promise.resolve(result);
} catch (err) {
return Promise.reject(err);

View File

@@ -12,7 +12,7 @@ suite('OpenerService', function () {
const editorService = new TestCodeEditorService();
let lastCommand: { id: string, args: any[] };
let lastCommand: { id: string, args: any[] } | undefined;
const commandService = new class implements ICommandService {
_serviceBrand: any;
@@ -30,7 +30,7 @@ suite('OpenerService', function () {
test('delegate to editorService, scheme:///fff', function () {
const openerService = new OpenerService(editorService, NullCommandService);
openerService.open(URI.parse('another:///somepath'));
assert.equal(editorService.lastInput.options.selection, undefined);
assert.equal(editorService.lastInput.options!.selection, undefined);
});
test('delegate to editorService, scheme:///fff#L123', function () {
@@ -38,21 +38,21 @@ suite('OpenerService', function () {
const openerService = new OpenerService(editorService, NullCommandService);
openerService.open(URI.parse('file:///somepath#L23'));
assert.equal(editorService.lastInput.options.selection.startLineNumber, 23);
assert.equal(editorService.lastInput.options.selection.startColumn, 1);
assert.equal(editorService.lastInput.options.selection.endLineNumber, undefined);
assert.equal(editorService.lastInput.options.selection.endColumn, undefined);
assert.equal(editorService.lastInput.options!.selection!.startLineNumber, 23);
assert.equal(editorService.lastInput.options!.selection!.startColumn, 1);
assert.equal(editorService.lastInput.options!.selection!.endLineNumber, undefined);
assert.equal(editorService.lastInput.options!.selection!.endColumn, undefined);
assert.equal(editorService.lastInput.resource.fragment, '');
openerService.open(URI.parse('another:///somepath#L23'));
assert.equal(editorService.lastInput.options.selection.startLineNumber, 23);
assert.equal(editorService.lastInput.options.selection.startColumn, 1);
assert.equal(editorService.lastInput.options!.selection!.startLineNumber, 23);
assert.equal(editorService.lastInput.options!.selection!.startColumn, 1);
openerService.open(URI.parse('another:///somepath#L23,45'));
assert.equal(editorService.lastInput.options.selection.startLineNumber, 23);
assert.equal(editorService.lastInput.options.selection.startColumn, 45);
assert.equal(editorService.lastInput.options.selection.endLineNumber, undefined);
assert.equal(editorService.lastInput.options.selection.endColumn, undefined);
assert.equal(editorService.lastInput.options!.selection!.startLineNumber, 23);
assert.equal(editorService.lastInput.options!.selection!.startColumn, 45);
assert.equal(editorService.lastInput.options!.selection!.endLineNumber, undefined);
assert.equal(editorService.lastInput.options!.selection!.endColumn, undefined);
assert.equal(editorService.lastInput.resource.fragment, '');
});
@@ -61,17 +61,17 @@ suite('OpenerService', function () {
const openerService = new OpenerService(editorService, NullCommandService);
openerService.open(URI.parse('file:///somepath#23'));
assert.equal(editorService.lastInput.options.selection.startLineNumber, 23);
assert.equal(editorService.lastInput.options.selection.startColumn, 1);
assert.equal(editorService.lastInput.options.selection.endLineNumber, undefined);
assert.equal(editorService.lastInput.options.selection.endColumn, undefined);
assert.equal(editorService.lastInput.options!.selection!.startLineNumber, 23);
assert.equal(editorService.lastInput.options!.selection!.startColumn, 1);
assert.equal(editorService.lastInput.options!.selection!.endLineNumber, undefined);
assert.equal(editorService.lastInput.options!.selection!.endColumn, undefined);
assert.equal(editorService.lastInput.resource.fragment, '');
openerService.open(URI.parse('file:///somepath#23,45'));
assert.equal(editorService.lastInput.options.selection.startLineNumber, 23);
assert.equal(editorService.lastInput.options.selection.startColumn, 45);
assert.equal(editorService.lastInput.options.selection.endLineNumber, undefined);
assert.equal(editorService.lastInput.options.selection.endColumn, undefined);
assert.equal(editorService.lastInput.options!.selection!.startLineNumber, 23);
assert.equal(editorService.lastInput.options!.selection!.startColumn, 45);
assert.equal(editorService.lastInput.options!.selection!.endLineNumber, undefined);
assert.equal(editorService.lastInput.options!.selection!.endColumn, undefined);
assert.equal(editorService.lastInput.resource.fragment, '');
});
@@ -79,28 +79,22 @@ suite('OpenerService', function () {
const openerService = new OpenerService(editorService, commandService);
// unknown command
openerService.open(URI.parse('command:foobar'));
assert.equal(lastCommand, undefined);
assert.equal(editorService.lastInput.resource.toString(), 'command:foobar');
assert.equal(editorService.lastInput.options.selection, undefined);
const id = `aCommand${Math.random()}`;
CommandsRegistry.registerCommand(id, function () { });
openerService.open(URI.parse('command:' + id));
assert.equal(lastCommand.id, id);
assert.equal(lastCommand.args.length, 0);
assert.equal(lastCommand!.id, id);
assert.equal(lastCommand!.args.length, 0);
openerService.open(URI.parse('command:' + id).with({ query: '123' }));
assert.equal(lastCommand.id, id);
assert.equal(lastCommand.args.length, 1);
assert.equal(lastCommand.args[0], '123');
assert.equal(lastCommand!.id, id);
assert.equal(lastCommand!.args.length, 1);
assert.equal(lastCommand!.args[0], '123');
openerService.open(URI.parse('command:' + id).with({ query: JSON.stringify([12, true]) }));
assert.equal(lastCommand.id, id);
assert.equal(lastCommand.args.length, 2);
assert.equal(lastCommand.args[0], 12);
assert.equal(lastCommand.args[1], true);
assert.equal(lastCommand!.id, id);
assert.equal(lastCommand!.args.length, 2);
assert.equal(lastCommand!.args[0], 12);
assert.equal(lastCommand!.args[1], true);
});
});

View File

@@ -73,18 +73,18 @@ export interface TestCodeEditorCreationOptions extends editorOptions.IEditorOpti
serviceCollection?: ServiceCollection;
}
export function withTestCodeEditor(text: string | string[], options: TestCodeEditorCreationOptions, callback: (editor: TestCodeEditor, cursor: Cursor | undefined) => void): void {
export function withTestCodeEditor(text: string | string[] | null, options: TestCodeEditorCreationOptions, callback: (editor: TestCodeEditor, cursor: Cursor) => void): void {
// create a model if necessary and remember it in order to dispose it.
if (!options.model) {
if (typeof text === 'string') {
options.model = TextModel.createFromString(text);
} else {
} else if (text) {
options.model = TextModel.createFromString(text.join('\n'));
}
}
let editor = <TestCodeEditor>createTestCodeEditor(options);
callback(editor, editor.getCursor());
callback(editor, editor.getCursor()!);
editor.dispose();
}

View File

@@ -14,7 +14,7 @@ import { withTestCodeEditor } from 'vs/editor/test/browser/testCodeEditor';
export function testCommand(
lines: string[],
languageIdentifier: LanguageIdentifier,
languageIdentifier: LanguageIdentifier | null,
selection: Selection,
commandFactory: (selection: Selection) => editorCommon.ICommand,
expectedLines: string[],