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

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