/*--------------------------------------------------------------------------------------------- * Copyright (c) Microsoft Corporation. All rights reserved. * Licensed under the MIT License. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ import * as nls from '../../../../vs/nls'; import { createMatches } from '../../../../vs/base/common/filters'; import { DisposableStore } from '../../../../vs/base/common/lifecycle'; import { append, $, hide, show } from '../../../../vs/base/browser/dom'; import { IListRenderer } from '../../../../vs/base/browser/ui/list/list'; import { EditorOption } from '../../../../vs/editor/common/config/editorOptions'; import { ICodeEditor } from '../../../../vs/editor/browser/editorBrowser'; import { CompletionItem } from './suggest'; import { IThemeService, ThemeIcon, } from '../../../../vs/platform/theme/common/themeService'; import { IModeService } from '../../../../vs/editor/common/services/modeService'; import { CompletionItemKind, completionKindToCssClass, CompletionItemTag, } from '../../../../vs/editor/common/modes'; import { IconLabel, IIconLabelValueOptions, } from '../../../../vs/base/browser/ui/iconLabel/iconLabel'; import { getIconClasses } from '../../../../vs/editor/common/services/getIconClasses'; import { IModelService } from '../../../../vs/editor/common/services/modelService'; import { URI } from '../../../../vs/base/common/uri'; import { FileKind } from '../../../../vs/platform/files/common/files'; import { flatten } from '../../../../vs/base/common/arrays'; import { canExpandCompletionItem } from './suggestWidgetDetails'; import { Codicon } from '../../../../vs/base/common/codicons'; import { Emitter, Event } from '../../../../vs/base/common/event'; import { registerIcon } from '../../../../vs/platform/theme/common/iconRegistry'; export function getAriaId(index: number): string { return `suggest-aria-id:${index}`; } export const suggestMoreInfoIcon = registerIcon( 'suggest-more-info', Codicon.chevronRight, nls.localize( 'suggestMoreInfoIcon', 'Icon for more information in the suggest widget.' ) ); const _completionItemColor = new (class ColorExtractor { private static _regexRelaxed = /(#([\da-fA-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*\))/; private static _regexStrict = new RegExp( `^${ColorExtractor._regexRelaxed.source}$`, 'i' ); extract(item: CompletionItem, out: string[]): boolean { if (item.textLabel.match(ColorExtractor._regexStrict)) { out[0] = item.textLabel; return true; } if ( item.completion.detail && item.completion.detail.match(ColorExtractor._regexStrict) ) { out[0] = item.completion.detail; return true; } if (typeof item.completion.documentation === 'string') { const match = ColorExtractor._regexRelaxed.exec( item.completion.documentation ); if ( match && (match.index === 0 || match.index + match[0].length === item.completion.documentation.length) ) { out[0] = match[0]; return true; } } return false; } })(); export interface ISuggestionTemplateData { root: HTMLElement; /** * Flexbox * < ------------- left ------------ > < --- right -- > *