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

perf - tweak defaultComparator

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