Dont repeat hex color suggestions in emmet Fixes #32232
This commit is contained in:
parent
994bfe6903
commit
6c7fe5b95b
2 changed files with 8 additions and 0 deletions
|
@ -194,6 +194,7 @@ function validateTextDocument(textDocument: TextDocument): void {
|
|||
}
|
||||
|
||||
let cachedCompletionList: CompletionList;
|
||||
const hexColorRegex = /^#[\d,a-f,A-F]{1,6}$/;
|
||||
connection.onCompletion(textDocumentPosition => {
|
||||
return runSafe(() => {
|
||||
let document = documents.get(textDocumentPosition.textDocument.uri);
|
||||
|
@ -223,6 +224,9 @@ connection.onCompletion(textDocumentPosition => {
|
|||
const result = getLanguageService(document).doComplete(document, textDocumentPosition.position, stylesheets.get(document))!; /* TODO: remove ! once LS has null annotations */
|
||||
if (emmetCompletionList && emmetCompletionList.items) {
|
||||
cachedCompletionList = result;
|
||||
if (emmetCompletionList.items.length && hexColorRegex.test(emmetCompletionList.items[0].label) && result.items.some(x => x.label === emmetCompletionList.items[0].label)) {
|
||||
emmetCompletionList.items.shift();
|
||||
}
|
||||
return { isIncomplete: true, items: [...emmetCompletionList.items, ...result.items] };
|
||||
}
|
||||
return result;
|
||||
|
|
|
@ -238,6 +238,7 @@ async function validateTextDocument(textDocument: TextDocument) {
|
|||
}
|
||||
|
||||
let cachedCompletionList: CompletionList;
|
||||
const hexColorRegex = /^#[\d,a-f,A-F]{1,6}$/;
|
||||
connection.onCompletion(async textDocumentPosition => {
|
||||
return runSafe(async () => {
|
||||
let document = documents.get(textDocumentPosition.textDocument.uri);
|
||||
|
@ -280,6 +281,9 @@ connection.onCompletion(async textDocumentPosition => {
|
|||
let result = mode.doComplete(document, textDocumentPosition.position, settings);
|
||||
if (emmetCompletionList && emmetCompletionList.items) {
|
||||
cachedCompletionList = result;
|
||||
if (emmetCompletionList.items.length && hexColorRegex.test(emmetCompletionList.items[0].label) && result.items.some(x => x.label === emmetCompletionList.items[0].label)) {
|
||||
emmetCompletionList.items.shift();
|
||||
}
|
||||
return { isIncomplete: true, items: [...emmetCompletionList.items, ...result.items] };
|
||||
}
|
||||
return result;
|
||||
|
|
Loading…
Reference in a new issue