提交 19e63edf 编写于 作者: J Johannes Rieken

perf - tweak defaultComparator

上级 e808161b
...@@ -274,7 +274,6 @@ export enum CompletionItemKind { ...@@ -274,7 +274,6 @@ export enum CompletionItemKind {
Enum, Enum,
EnumMember, EnumMember,
Keyword, Keyword,
Snippet,
Text, Text,
Color, Color,
File, File,
...@@ -282,6 +281,7 @@ export enum CompletionItemKind { ...@@ -282,6 +281,7 @@ export enum CompletionItemKind {
Customcolor, Customcolor,
Folder, Folder,
TypeParameter, TypeParameter,
Snippet, // <- highest value (used for compare!)
} }
/** /**
......
...@@ -166,33 +166,22 @@ function createSuggesionFilter(snippetConfig: SnippetConfig): (candidate: Comple ...@@ -166,33 +166,22 @@ function createSuggesionFilter(snippetConfig: SnippetConfig): (candidate: Comple
} }
} }
function defaultComparator(a: ISuggestionItem, b: ISuggestionItem): number { function defaultComparator(a: ISuggestionItem, b: ISuggestionItem): number {
// check with 'sortText' // check with 'sortText'
if (typeof a.suggestion.sortText === 'string' && typeof b.suggestion.sortText === 'string') { if (a.suggestion._sortTextLow && b.suggestion._sortTextLow) {
if (a.suggestion._sortTextLow < b.suggestion._sortTextLow) { if (a.suggestion._sortTextLow < b.suggestion._sortTextLow) {
return -1; return -1;
} else if (a.suggestion._sortTextLow > b.suggestion._sortTextLow) { } else if (a.suggestion._sortTextLow > b.suggestion._sortTextLow) {
return 1; return 1;
} }
} }
// check with 'label' // check with 'label'
if (a.suggestion.label < b.suggestion.label) { if (a.suggestion.label < b.suggestion.label) {
return -1; return -1;
} else if (a.suggestion.label > b.suggestion.label) { } else if (a.suggestion.label > b.suggestion.label) {
return 1; return 1;
} }
// check with 'type'
// check with 'type' and lower snippets return a.suggestion.kind - b.suggestion.kind;
if (a.suggestion.kind !== b.suggestion.kind) {
if (a.suggestion.kind === CompletionItemKind.Snippet) {
return 1;
} else if (b.suggestion.kind === CompletionItemKind.Snippet) {
return -1;
}
}
return 0;
} }
function snippetUpComparator(a: ISuggestionItem, b: ISuggestionItem): number { function snippetUpComparator(a: ISuggestionItem, b: ISuggestionItem): number {
......
...@@ -4668,14 +4668,14 @@ declare namespace monaco.languages { ...@@ -4668,14 +4668,14 @@ declare namespace monaco.languages {
Enum = 15, Enum = 15,
EnumMember = 16, EnumMember = 16,
Keyword = 17, Keyword = 17,
Snippet = 18, Text = 18,
Text = 19, Color = 19,
Color = 20, File = 20,
File = 21, Reference = 21,
Reference = 22, Customcolor = 22,
Customcolor = 23, Folder = 23,
Folder = 24, TypeParameter = 24,
TypeParameter = 25 Snippet = 25
} }
/** /**
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册