提交 62e0f34a 编写于 作者: J Johannes Rieken

add CompletionItem#preselect, #35551

上级 5bde5c11
......@@ -293,7 +293,7 @@ export interface ISuggestion {
documentation?: string | IMarkdownString;
filterText?: string;
sortText?: string;
autoSelect?: boolean;
preselect?: boolean;
noAutoAccept?: boolean;
commitCharacters?: string[];
overwriteBefore?: number;
......
......@@ -24,7 +24,7 @@ export abstract class Memory {
// stop when leaving the group of top matches
break;
}
if (suggestion.autoSelect) {
if (suggestion.preselect) {
// stop when seeing an auto-select-item
return i;
}
......
......@@ -45,9 +45,9 @@ suite('SuggestMemories', function () {
let item2 = createSuggestItem('bazz', 0);
let item3 = createSuggestItem('bazz', 0);
let item4 = createSuggestItem('bazz', 0);
item1.suggestion.autoSelect = false;
item2.suggestion.autoSelect = true;
item3.suggestion.autoSelect = true;
item1.suggestion.preselect = false;
item2.suggestion.preselect = true;
item3.suggestion.preselect = true;
assert.equal(mem.select(buffer, pos, [item1, item2, item3, item4]), 1);
});
......@@ -57,9 +57,9 @@ suite('SuggestMemories', function () {
let item2 = createSuggestItem('bazz', 0);
let item3 = createSuggestItem('bazz', 0);
let item4 = createSuggestItem('bazz', 0);
item1.suggestion.autoSelect = false;
item2.suggestion.autoSelect = true;
item3.suggestion.autoSelect = true;
item1.suggestion.preselect = false;
item2.suggestion.preselect = true;
item3.suggestion.preselect = true;
let items = [item1, item2, item3, item4];
......
......@@ -3105,6 +3105,13 @@ declare module 'vscode' {
*/
filterText?: string;
/**
* Select this item when showing. *Note* that only one completion item can be selected and
* that the editor decides which item that is. The rule is that the *first* item of those
* that match best is selected.
*/
preselect?: boolean;
/**
* A string or snippet that should be inserted in a document when selecting
* this completion. When `falsy` the [label](#CompletionItem.label)
......
......@@ -662,6 +662,7 @@ class SuggestAdapter {
documentation: item.documentation,
filterText: item.filterText,
sortText: item.sortText,
preselect: item.preselect,
//
insertText: undefined,
additionalTextEdits: item.additionalTextEdits && item.additionalTextEdits.map(typeConvert.TextEdit.from),
......
......@@ -1073,7 +1073,7 @@ export enum CompletionItemKind {
TypeParameter = 24
}
export class CompletionItem {
export class CompletionItem implements vscode.CompletionItem {
label: string;
kind: CompletionItemKind;
......@@ -1081,6 +1081,7 @@ export class CompletionItem {
documentation: string | MarkdownString;
sortText: string;
filterText: string;
preselect: boolean;
insertText: string | SnippetString;
range: Range;
textEdit: TextEdit;
......@@ -1100,6 +1101,7 @@ export class CompletionItem {
documentation: this.documentation,
sortText: this.sortText,
filterText: this.filterText,
preselect: this.preselect,
insertText: this.insertText,
textEdit: this.textEdit
};
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册