Skip to content

Commit

Permalink
fix #68269, again...
Browse files Browse the repository at this point in the history
  • Loading branch information
jrieken committed Feb 14, 2019
1 parent d8529d7 commit 86e9f7e
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions src/vs/editor/contrib/suggest/suggestWidget.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,16 @@ export const editorSuggestWidgetHighlightForeground = registerColor('editorSugge


const colorRegExp = /^(#([\da-f]{3}){1,2}|(rgb|hsl)a\(\s*(\d{1,3}%?\s*,\s*){3}(1|0?\.\d+)\)|(rgb|hsl)\(\s*\d{1,3}%?(\s*,\s*\d{1,3}%?){2}\s*\))$/i;
function matchesColor(text: string): string | null {
return text && text.match(colorRegExp) ? text : null;
function extractColor(item: CompletionItem, out: string[]): boolean {
if (item.completion.label.match(colorRegExp)) {
out[0] = item.completion.label;
return true;
}
if (typeof item.completion.documentation === 'string' && item.completion.documentation.match(colorRegExp)) {
out[0] = item.completion.documentation;
return true;
}
return false;
}

function canExpandCompletionItem(item: CompletionItem | null) {
Expand Down Expand Up @@ -156,11 +164,11 @@ class Renderer implements IListRenderer<CompletionItem, ISuggestionTemplateData>
matches: createMatches(element.score)
};

let color: string | null = null;
if (suggestion.kind === CompletionItemKind.Color && ((color = matchesColor(suggestion.label) || typeof suggestion.documentation === 'string' ? matchesColor(suggestion.documentation as any) : null))) {
let color: string[] = [];
if (suggestion.kind === CompletionItemKind.Color && extractColor(element, color)) {
// special logic for 'color' completion items
data.icon.className = 'icon customcolor';
data.colorspan.style.backgroundColor = color;
data.colorspan.style.backgroundColor = color[0];

} else if (suggestion.kind === CompletionItemKind.File && this._themeService.getIconTheme().hasFileIcons) {
// special logic for 'file' completion items
Expand Down

0 comments on commit 86e9f7e

Please sign in to comment.