Dont repeat hex color suggestions in emmet Fixes #32232

This commit is contained in:
Ramya Achutha Rao
2018-02-13 17:41:53 -08:00
parent 994bfe6903
commit 6c7fe5b95b
2 changed files with 8 additions and 0 deletions

View File

@@ -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;