mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-03-21 20:30:29 -04:00
Merge VS Code 1.21 source code (#1067)
* Initial VS Code 1.21 file copy with patches * A few more merges * Post npm install * Fix batch of build breaks * Fix more build breaks * Fix more build errors * Fix more build breaks * Runtime fixes 1 * Get connection dialog working with some todos * Fix a few packaging issues * Copy several node_modules to package build to fix loader issues * Fix breaks from master * A few more fixes * Make tests pass * First pass of license header updates * Second pass of license header updates * Fix restore dialog issues * Remove add additional themes menu items * fix select box issues where the list doesn't show up * formatting * Fix editor dispose issue * Copy over node modules to correct location on all platforms
This commit is contained in:
@@ -11,37 +11,37 @@ import { CompletionModel } from 'vs/editor/contrib/suggest/completionModel';
|
||||
import { IPosition } from 'vs/editor/common/core/position';
|
||||
import { TPromise } from 'vs/base/common/winjs.base';
|
||||
|
||||
suite('CompletionModel', function () {
|
||||
export function createSuggestItem(label: string, overwriteBefore: number, type: SuggestionType = 'property', incomplete: boolean = false, position: IPosition = { lineNumber: 1, column: 1 }): ISuggestionItem {
|
||||
|
||||
function createSuggestItem(label: string, overwriteBefore: number, type: SuggestionType = 'property', incomplete: boolean = false, position: IPosition = { lineNumber: 1, column: 1 }): ISuggestionItem {
|
||||
return new class implements ISuggestionItem {
|
||||
|
||||
return new class implements ISuggestionItem {
|
||||
position = position;
|
||||
|
||||
position = position;
|
||||
suggestion: ISuggestion = {
|
||||
label,
|
||||
overwriteBefore,
|
||||
insertText: label,
|
||||
type
|
||||
};
|
||||
|
||||
suggestion: ISuggestion = {
|
||||
label,
|
||||
overwriteBefore,
|
||||
insertText: label,
|
||||
type
|
||||
};
|
||||
container: ISuggestResult = {
|
||||
incomplete,
|
||||
suggestions: [this.suggestion]
|
||||
};
|
||||
|
||||
container: ISuggestResult = {
|
||||
incomplete,
|
||||
suggestions: [this.suggestion]
|
||||
};
|
||||
|
||||
support: ISuggestSupport = {
|
||||
provideCompletionItems(): any {
|
||||
return;
|
||||
}
|
||||
};
|
||||
|
||||
resolve(): TPromise<void> {
|
||||
return null;
|
||||
support: ISuggestSupport = {
|
||||
provideCompletionItems(): any {
|
||||
return;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
resolve(): TPromise<void> {
|
||||
return null;
|
||||
}
|
||||
};
|
||||
}
|
||||
suite('CompletionModel', function () {
|
||||
|
||||
|
||||
let model: CompletionModel;
|
||||
|
||||
|
||||
@@ -10,17 +10,17 @@ import { IDisposable } from 'vs/base/common/lifecycle';
|
||||
import { SuggestRegistry } from 'vs/editor/common/modes';
|
||||
import { provideSuggestionItems } from 'vs/editor/contrib/suggest/suggest';
|
||||
import { Position } from 'vs/editor/common/core/position';
|
||||
import { Model } from 'vs/editor/common/model/model';
|
||||
import { TextModel } from 'vs/editor/common/model/textModel';
|
||||
|
||||
|
||||
suite('Suggest', function () {
|
||||
|
||||
let model: Model;
|
||||
let model: TextModel;
|
||||
let registration: IDisposable;
|
||||
|
||||
setup(function () {
|
||||
|
||||
model = Model.createFromString('FOO\nbar\BAR\nfoo', undefined, undefined, URI.parse('foo:bar/path'));
|
||||
model = TextModel.createFromString('FOO\nbar\BAR\nfoo', undefined, undefined, URI.parse('foo:bar/path'));
|
||||
registration = SuggestRegistry.register({ pattern: 'bar/path', scheme: 'foo' }, {
|
||||
provideCompletionItems() {
|
||||
return {
|
||||
|
||||
86
src/vs/editor/contrib/suggest/test/suggestMemory.test.ts
Normal file
86
src/vs/editor/contrib/suggest/test/suggestMemory.test.ts
Normal file
@@ -0,0 +1,86 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
'use strict';
|
||||
|
||||
import * as assert from 'assert';
|
||||
import { LRUMemory, NoMemory, PrefixMemory } from 'vs/editor/contrib/suggest/suggestMemory';
|
||||
import { ITextModel } from 'vs/editor/common/model';
|
||||
import { TextModel } from 'vs/editor/common/model/textModel';
|
||||
import { ICompletionItem } from 'vs/editor/contrib/suggest/completionModel';
|
||||
import { createSuggestItem } from 'vs/editor/contrib/suggest/test/completionModel.test';
|
||||
import { IPosition } from 'vs/editor/common/core/position';
|
||||
|
||||
suite('SuggestMemories', function () {
|
||||
|
||||
let pos: IPosition;
|
||||
let buffer: ITextModel;
|
||||
let items: ICompletionItem[];
|
||||
|
||||
setup(function () {
|
||||
pos = { lineNumber: 1, column: 1 };
|
||||
buffer = TextModel.createFromString('This is some text');
|
||||
items = [
|
||||
createSuggestItem('foo', 0),
|
||||
createSuggestItem('bar', 0)
|
||||
];
|
||||
});
|
||||
|
||||
test('NoMemory', function () {
|
||||
|
||||
const mem = new NoMemory();
|
||||
|
||||
assert.equal(mem.select(buffer, pos, items), 0);
|
||||
assert.equal(mem.select(buffer, pos, []), 0);
|
||||
|
||||
mem.memorize(buffer, pos, items[0]);
|
||||
mem.memorize(buffer, pos, null);
|
||||
});
|
||||
|
||||
test('ShyMemories', function () {
|
||||
|
||||
const mem = new LRUMemory();
|
||||
mem.memorize(buffer, pos, items[1]);
|
||||
|
||||
assert.equal(mem.select(buffer, pos, items), 1);
|
||||
assert.equal(mem.select(buffer, { lineNumber: 1, column: 3 }, items), 0);
|
||||
|
||||
mem.memorize(buffer, pos, items[0]);
|
||||
assert.equal(mem.select(buffer, pos, items), 0);
|
||||
|
||||
assert.equal(mem.select(buffer, pos, [
|
||||
createSuggestItem('new', 0),
|
||||
createSuggestItem('bar', 0)
|
||||
]), 1);
|
||||
|
||||
assert.equal(mem.select(buffer, pos, [
|
||||
createSuggestItem('new1', 0),
|
||||
createSuggestItem('new2', 0)
|
||||
]), 0);
|
||||
|
||||
});
|
||||
|
||||
test('PrefixMemory', function () {
|
||||
|
||||
const mem = new PrefixMemory();
|
||||
buffer.setValue('constructor');
|
||||
const item0 = createSuggestItem('console', 0);
|
||||
const item1 = createSuggestItem('const', 0);
|
||||
const item2 = createSuggestItem('constructor', 0);
|
||||
const item3 = createSuggestItem('constant', 0);
|
||||
const items = [item0, item1, item2, item3];
|
||||
|
||||
mem.memorize(buffer, { lineNumber: 1, column: 2 }, item1); // c -> const
|
||||
mem.memorize(buffer, { lineNumber: 1, column: 3 }, item0); // co -> console
|
||||
mem.memorize(buffer, { lineNumber: 1, column: 4 }, item2); // con -> constructor
|
||||
|
||||
assert.equal(mem.select(buffer, { lineNumber: 1, column: 1 }, items), 0);
|
||||
assert.equal(mem.select(buffer, { lineNumber: 1, column: 2 }, items), 1);
|
||||
assert.equal(mem.select(buffer, { lineNumber: 1, column: 3 }, items), 0);
|
||||
assert.equal(mem.select(buffer, { lineNumber: 1, column: 4 }, items), 2);
|
||||
assert.equal(mem.select(buffer, { lineNumber: 1, column: 7 }, items), 2); // find substr
|
||||
});
|
||||
|
||||
});
|
||||
@@ -8,8 +8,7 @@ import * as assert from 'assert';
|
||||
import Event from 'vs/base/common/event';
|
||||
import URI from 'vs/base/common/uri';
|
||||
import { IDisposable, dispose } from 'vs/base/common/lifecycle';
|
||||
import { TPromise } from 'vs/base/common/winjs.base';
|
||||
import { Model } from 'vs/editor/common/model/model';
|
||||
import { TextModel } from 'vs/editor/common/model/textModel';
|
||||
import { Handler } from 'vs/editor/common/editorCommon';
|
||||
import { ISuggestSupport, ISuggestResult, SuggestRegistry, SuggestTriggerKind } from 'vs/editor/common/modes';
|
||||
import { SuggestModel, LineContext } from 'vs/editor/contrib/suggest/suggestModel';
|
||||
@@ -22,15 +21,19 @@ import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry';
|
||||
import { NullTelemetryService } from 'vs/platform/telemetry/common/telemetryUtils';
|
||||
import { EditOperation } from 'vs/editor/common/core/editOperation';
|
||||
import { Range } from 'vs/editor/common/core/range';
|
||||
import { ICodeEditor } from 'vs/editor/browser/editorBrowser';
|
||||
import { CoreEditingCommands } from 'vs/editor/browser/controller/coreCommands';
|
||||
import { SuggestController } from 'vs/editor/contrib/suggest/suggestController';
|
||||
import { IStorageService, NullStorageService } from 'vs/platform/storage/common/storage';
|
||||
import { SnippetController2 } from 'vs/editor/contrib/snippet/snippetController2';
|
||||
import { ISelectedSuggestion } from 'vs/editor/contrib/suggest/suggestWidget';
|
||||
|
||||
function createMockEditor(model: Model): TestCodeEditor {
|
||||
function createMockEditor(model: TextModel): TestCodeEditor {
|
||||
const contextKeyService = new MockContextKeyService();
|
||||
const telemetryService = NullTelemetryService;
|
||||
const instantiationService = new InstantiationService(new ServiceCollection(
|
||||
[IContextKeyService, contextKeyService],
|
||||
[ITelemetryService, telemetryService]
|
||||
[ITelemetryService, telemetryService],
|
||||
[IStorageService, NullStorageService]
|
||||
));
|
||||
|
||||
const editor = new TestCodeEditor(new MockScopeLocation(), {}, instantiationService, contextKeyService);
|
||||
@@ -40,10 +43,10 @@ function createMockEditor(model: Model): TestCodeEditor {
|
||||
|
||||
suite('SuggestModel - Context', function () {
|
||||
|
||||
let model: Model;
|
||||
let model: TextModel;
|
||||
|
||||
setup(function () {
|
||||
model = Model.createFromString('Das Pferd frisst keinen Gurkensalat - Philipp Reis 1861.\nWer hat\'s erfunden?');
|
||||
model = TextModel.createFromString('Das Pferd frisst keinen Gurkensalat - Philipp Reis 1861.\nWer hat\'s erfunden?');
|
||||
});
|
||||
|
||||
teardown(function () {
|
||||
@@ -94,17 +97,17 @@ suite('SuggestModel - TriggerAndCancelOracle', function () {
|
||||
};
|
||||
|
||||
let disposables: IDisposable[] = [];
|
||||
let model: Model;
|
||||
let model: TextModel;
|
||||
|
||||
setup(function () {
|
||||
disposables = dispose(disposables);
|
||||
model = Model.createFromString('abc def', undefined, undefined, URI.parse('test:somefile.ttt'));
|
||||
model = TextModel.createFromString('abc def', undefined, undefined, URI.parse('test:somefile.ttt'));
|
||||
disposables.push(model);
|
||||
});
|
||||
|
||||
function withOracle(callback: (model: SuggestModel, editor: ICodeEditor) => any): TPromise<any> {
|
||||
function withOracle(callback: (model: SuggestModel, editor: TestCodeEditor) => any): Promise<any> {
|
||||
|
||||
return new TPromise((resolve, reject) => {
|
||||
return new Promise((resolve, reject) => {
|
||||
const editor = createMockEditor(model);
|
||||
const oracle = new SuggestModel(editor);
|
||||
disposables.push(oracle, editor);
|
||||
@@ -118,7 +121,7 @@ suite('SuggestModel - TriggerAndCancelOracle', function () {
|
||||
}
|
||||
|
||||
function assertEvent<E>(event: Event<E>, action: () => any, assert: (e: E) => any) {
|
||||
return new TPromise((resolve, reject) => {
|
||||
return new Promise((resolve, reject) => {
|
||||
const sub = event(e => {
|
||||
sub.dispose();
|
||||
try {
|
||||
@@ -138,7 +141,7 @@ suite('SuggestModel - TriggerAndCancelOracle', function () {
|
||||
test('events - cancel/trigger', function () {
|
||||
return withOracle(model => {
|
||||
|
||||
return TPromise.join([
|
||||
return Promise.all([
|
||||
assertEvent(model.onDidCancel, function () {
|
||||
model.cancel();
|
||||
}, function (event) {
|
||||
@@ -185,7 +188,7 @@ suite('SuggestModel - TriggerAndCancelOracle', function () {
|
||||
disposables.push(SuggestRegistry.register({ scheme: 'test' }, alwaysEmptySupport));
|
||||
|
||||
return withOracle(model => {
|
||||
return TPromise.join([
|
||||
return Promise.all([
|
||||
assertEvent(model.onDidCancel, function () {
|
||||
model.trigger({ auto: true });
|
||||
}, function (event) {
|
||||
@@ -564,4 +567,53 @@ suite('SuggestModel - TriggerAndCancelOracle', function () {
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
test('Text changes for completion CodeAction are affected by the completion #39893', function () {
|
||||
disposables.push(SuggestRegistry.register({ scheme: 'test' }, {
|
||||
provideCompletionItems(doc, pos): ISuggestResult {
|
||||
return {
|
||||
incomplete: true,
|
||||
suggestions: [{
|
||||
label: 'bar',
|
||||
type: 'property',
|
||||
insertText: 'bar',
|
||||
overwriteBefore: 2,
|
||||
additionalTextEdits: [{
|
||||
text: ', bar',
|
||||
range: { startLineNumber: 1, endLineNumber: 1, startColumn: 17, endColumn: 17 }
|
||||
}]
|
||||
}]
|
||||
};
|
||||
}
|
||||
}));
|
||||
|
||||
model.setValue('ba; import { foo } from "./b"');
|
||||
|
||||
return withOracle(async (sugget, editor) => {
|
||||
class TestCtrl extends SuggestController {
|
||||
_onDidSelectItem(item: ISelectedSuggestion) {
|
||||
super._onDidSelectItem(item);
|
||||
}
|
||||
}
|
||||
const ctrl = <TestCtrl>editor.registerAndInstantiateContribution(TestCtrl);
|
||||
editor.registerAndInstantiateContribution(SnippetController2);
|
||||
|
||||
await assertEvent(sugget.onDidSuggest, () => {
|
||||
editor.setPosition({ lineNumber: 1, column: 3 });
|
||||
sugget.trigger({ auto: false });
|
||||
}, event => {
|
||||
|
||||
assert.equal(event.completionModel.items.length, 1);
|
||||
const [first] = event.completionModel.items;
|
||||
assert.equal(first.suggestion.label, 'bar');
|
||||
|
||||
ctrl._onDidSelectItem({ item: first, index: 0, model: event.completionModel });
|
||||
});
|
||||
|
||||
assert.equal(
|
||||
model.getValue(),
|
||||
'bar; import { foo, bar } from "./b"'
|
||||
);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user