mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-03-21 20:30:29 -04:00
Merge VS Code 1.31.1 (#4283)
This commit is contained in:
@@ -4,39 +4,31 @@
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
import * as assert from 'assert';
|
||||
import { IPosition } from 'vs/editor/common/core/position';
|
||||
import { CompletionList, CompletionItemProvider, CompletionItem, CompletionItemKind } from 'vs/editor/common/modes';
|
||||
import * as modes from 'vs/editor/common/modes';
|
||||
import { CompletionModel } from 'vs/editor/contrib/suggest/completionModel';
|
||||
import { ISuggestionItem, getSuggestionComparator, ensureLowerCaseVariants } from 'vs/editor/contrib/suggest/suggest';
|
||||
import { CompletionItem, getSuggestionComparator } from 'vs/editor/contrib/suggest/suggest';
|
||||
import { WordDistance } from 'vs/editor/contrib/suggest/wordDistance';
|
||||
|
||||
export function createSuggestItem(label: string, overwriteBefore: number, kind = CompletionItemKind.Property, incomplete: boolean = false, position: IPosition = { lineNumber: 1, column: 1 }): ISuggestionItem {
|
||||
|
||||
return new class implements ISuggestionItem {
|
||||
|
||||
position = position;
|
||||
|
||||
suggestion: CompletionItem = {
|
||||
label,
|
||||
range: { startLineNumber: position.lineNumber, startColumn: position.column - overwriteBefore, endLineNumber: position.lineNumber, endColumn: position.column },
|
||||
insertText: label,
|
||||
kind
|
||||
};
|
||||
|
||||
container: CompletionList = {
|
||||
incomplete,
|
||||
suggestions: [this.suggestion]
|
||||
};
|
||||
|
||||
support: CompletionItemProvider = {
|
||||
provideCompletionItems(): any {
|
||||
return;
|
||||
}
|
||||
};
|
||||
|
||||
resolve(): Promise<void> {
|
||||
return null;
|
||||
export function createSuggestItem(label: string, overwriteBefore: number, kind = modes.CompletionItemKind.Property, incomplete: boolean = false, position: IPosition = { lineNumber: 1, column: 1 }, sortText?: string, filterText?: string): CompletionItem {
|
||||
const suggestion: modes.CompletionItem = {
|
||||
label,
|
||||
sortText,
|
||||
filterText,
|
||||
range: { startLineNumber: position.lineNumber, startColumn: position.column - overwriteBefore, endLineNumber: position.lineNumber, endColumn: position.column },
|
||||
insertText: label,
|
||||
kind
|
||||
};
|
||||
const container: modes.CompletionList = {
|
||||
incomplete,
|
||||
suggestions: [suggestion]
|
||||
};
|
||||
const provider: modes.CompletionItemProvider = {
|
||||
provideCompletionItems(): any {
|
||||
return;
|
||||
}
|
||||
};
|
||||
|
||||
return new CompletionItem(position, suggestion, container, provider, undefined!);
|
||||
}
|
||||
suite('CompletionModel', function () {
|
||||
|
||||
@@ -100,7 +92,7 @@ suite('CompletionModel', function () {
|
||||
const complete = model.adopt(incomplete);
|
||||
|
||||
assert.equal(incomplete.size, 1);
|
||||
assert.ok(incomplete.has(incompleteItem.support));
|
||||
assert.ok(incomplete.has(incompleteItem.provider));
|
||||
assert.equal(complete.length, 1);
|
||||
assert.ok(complete[0] === completeItem);
|
||||
});
|
||||
@@ -130,7 +122,7 @@ suite('CompletionModel', function () {
|
||||
const complete = model.adopt(incomplete);
|
||||
|
||||
assert.equal(incomplete.size, 1);
|
||||
assert.ok(incomplete.has(incompleteItem1.support));
|
||||
assert.ok(incomplete.has(incompleteItem1.provider));
|
||||
assert.equal(complete.length, 5);
|
||||
});
|
||||
|
||||
@@ -150,18 +142,18 @@ suite('CompletionModel', function () {
|
||||
assert.equal(model.items.length, 4);
|
||||
|
||||
const [a, b, c, d] = model.items;
|
||||
assert.equal(a.suggestion.label, ' </div');
|
||||
assert.equal(b.suggestion.label, ' </tag');
|
||||
assert.equal(c.suggestion.label, 'a');
|
||||
assert.equal(d.suggestion.label, 'p');
|
||||
assert.equal(a.completion.label, ' </div');
|
||||
assert.equal(b.completion.label, ' </tag');
|
||||
assert.equal(c.completion.label, 'a');
|
||||
assert.equal(d.completion.label, 'p');
|
||||
});
|
||||
|
||||
test('keep snippet sorting with prefix: top, #25495', function () {
|
||||
|
||||
model = new CompletionModel([
|
||||
createSuggestItem('Snippet1', 1, CompletionItemKind.Snippet),
|
||||
createSuggestItem('tnippet2', 1, CompletionItemKind.Snippet),
|
||||
createSuggestItem('semver', 1, CompletionItemKind.Property),
|
||||
createSuggestItem('Snippet1', 1, modes.CompletionItemKind.Snippet),
|
||||
createSuggestItem('tnippet2', 1, modes.CompletionItemKind.Snippet),
|
||||
createSuggestItem('semver', 1, modes.CompletionItemKind.Property),
|
||||
], 1, {
|
||||
leadingLineContent: 's',
|
||||
characterCountDelta: 0
|
||||
@@ -169,8 +161,8 @@ suite('CompletionModel', function () {
|
||||
|
||||
assert.equal(model.items.length, 2);
|
||||
const [a, b] = model.items;
|
||||
assert.equal(a.suggestion.label, 'Snippet1');
|
||||
assert.equal(b.suggestion.label, 'semver');
|
||||
assert.equal(a.completion.label, 'Snippet1');
|
||||
assert.equal(b.completion.label, 'semver');
|
||||
assert.ok(a.score < b.score); // snippet really promoted
|
||||
|
||||
});
|
||||
@@ -178,9 +170,9 @@ suite('CompletionModel', function () {
|
||||
test('keep snippet sorting with prefix: bottom, #25495', function () {
|
||||
|
||||
model = new CompletionModel([
|
||||
createSuggestItem('snippet1', 1, CompletionItemKind.Snippet),
|
||||
createSuggestItem('tnippet2', 1, CompletionItemKind.Snippet),
|
||||
createSuggestItem('Semver', 1, CompletionItemKind.Property),
|
||||
createSuggestItem('snippet1', 1, modes.CompletionItemKind.Snippet),
|
||||
createSuggestItem('tnippet2', 1, modes.CompletionItemKind.Snippet),
|
||||
createSuggestItem('Semver', 1, modes.CompletionItemKind.Property),
|
||||
], 1, {
|
||||
leadingLineContent: 's',
|
||||
characterCountDelta: 0
|
||||
@@ -188,16 +180,16 @@ suite('CompletionModel', function () {
|
||||
|
||||
assert.equal(model.items.length, 2);
|
||||
const [a, b] = model.items;
|
||||
assert.equal(a.suggestion.label, 'Semver');
|
||||
assert.equal(b.suggestion.label, 'snippet1');
|
||||
assert.equal(a.completion.label, 'Semver');
|
||||
assert.equal(b.completion.label, 'snippet1');
|
||||
assert.ok(a.score < b.score); // snippet really demoted
|
||||
});
|
||||
|
||||
test('keep snippet sorting with prefix: inline, #25495', function () {
|
||||
|
||||
model = new CompletionModel([
|
||||
createSuggestItem('snippet1', 1, CompletionItemKind.Snippet),
|
||||
createSuggestItem('tnippet2', 1, CompletionItemKind.Snippet),
|
||||
createSuggestItem('snippet1', 1, modes.CompletionItemKind.Snippet),
|
||||
createSuggestItem('tnippet2', 1, modes.CompletionItemKind.Snippet),
|
||||
createSuggestItem('Semver', 1),
|
||||
], 1, {
|
||||
leadingLineContent: 's',
|
||||
@@ -206,15 +198,14 @@ suite('CompletionModel', function () {
|
||||
|
||||
assert.equal(model.items.length, 2);
|
||||
const [a, b] = model.items;
|
||||
assert.equal(a.suggestion.label, 'snippet1');
|
||||
assert.equal(b.suggestion.label, 'Semver');
|
||||
assert.equal(a.completion.label, 'snippet1');
|
||||
assert.equal(b.completion.label, 'Semver');
|
||||
assert.ok(a.score > b.score); // snippet really demoted
|
||||
});
|
||||
|
||||
test('filterText seems ignored in autocompletion, #26874', function () {
|
||||
|
||||
const item1 = createSuggestItem('Map - java.util', 1);
|
||||
item1.suggestion.filterText = 'Map';
|
||||
const item1 = createSuggestItem('Map - java.util', 1, undefined, undefined, undefined, undefined, 'Map');
|
||||
const item2 = createSuggestItem('Map - java.util', 1);
|
||||
|
||||
model = new CompletionModel([item1, item2], 1, {
|
||||
@@ -233,17 +224,8 @@ suite('CompletionModel', function () {
|
||||
|
||||
test('Vscode 1.12 no longer obeys \'sortText\' in completion items (from language server), #26096', function () {
|
||||
|
||||
const item1 = createSuggestItem('<- groups', 2, CompletionItemKind.Property, false, { lineNumber: 1, column: 3 });
|
||||
item1.suggestion.filterText = ' groups';
|
||||
item1.suggestion.sortText = '00002';
|
||||
|
||||
const item2 = createSuggestItem('source', 0, CompletionItemKind.Property, false, { lineNumber: 1, column: 3 });
|
||||
item2.suggestion.filterText = 'source';
|
||||
item2.suggestion.sortText = '00001';
|
||||
|
||||
ensureLowerCaseVariants(item1.suggestion);
|
||||
ensureLowerCaseVariants(item2.suggestion);
|
||||
|
||||
const item1 = createSuggestItem('<- groups', 2, modes.CompletionItemKind.Property, false, { lineNumber: 1, column: 3 }, '00002', ' groups');
|
||||
const item2 = createSuggestItem('source', 0, modes.CompletionItemKind.Property, false, { lineNumber: 1, column: 3 }, '00001', 'source');
|
||||
const items = [item1, item2].sort(getSuggestionComparator('inline'));
|
||||
|
||||
model = new CompletionModel(items, 3, {
|
||||
@@ -254,8 +236,8 @@ suite('CompletionModel', function () {
|
||||
assert.equal(model.items.length, 2);
|
||||
|
||||
const [first, second] = model.items;
|
||||
assert.equal(first.suggestion.label, 'source');
|
||||
assert.equal(second.suggestion.label, '<- groups');
|
||||
assert.equal(first.completion.label, 'source');
|
||||
assert.equal(second.completion.label, '<- groups');
|
||||
});
|
||||
|
||||
test('Score only filtered items when typing more, score all when typing less', function () {
|
||||
@@ -302,9 +284,9 @@ suite('CompletionModel', function () {
|
||||
assert.equal(model.items.length, 3);
|
||||
|
||||
const [first, second, third] = model.items;
|
||||
assert.equal(first.suggestion.label, 'result'); // best with `rult`
|
||||
assert.equal(second.suggestion.label, 'replyToUser'); // best with `rltu`
|
||||
assert.equal(third.suggestion.label, 'randomLolut'); // best with `rlut`
|
||||
assert.equal(first.completion.label, 'result'); // best with `rult`
|
||||
assert.equal(second.completion.label, 'replyToUser'); // best with `rltu`
|
||||
assert.equal(third.completion.label, 'randomLolut'); // best with `rlut`
|
||||
});
|
||||
|
||||
test('Emmet suggestion not appearing at the top of the list in jsx files, #39518', function () {
|
||||
@@ -322,8 +304,8 @@ suite('CompletionModel', function () {
|
||||
model.lineContext = { leadingLineContent: 'form', characterCountDelta: 4 };
|
||||
assert.equal(model.items.length, 5);
|
||||
const [first, second, third] = model.items;
|
||||
assert.equal(first.suggestion.label, 'form'); // best with `form`
|
||||
assert.equal(second.suggestion.label, 'form:get'); // best with `form`
|
||||
assert.equal(third.suggestion.label, 'from'); // best with `from`
|
||||
assert.equal(first.completion.label, 'form'); // best with `form`
|
||||
assert.equal(second.completion.label, 'form:get'); // best with `form`
|
||||
assert.equal(third.completion.label, 'from'); // best with `from`
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user