mirror of
https://github.com/coder/code-server.git
synced 2026-05-10 22:37:26 +02:00
Update to VS Code 1.52.1
This commit is contained in:
@@ -11,7 +11,7 @@ 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 } from 'vs/platform/theme/common/themeService';
|
||||
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';
|
||||
@@ -21,32 +21,40 @@ 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, registerIcon } from 'vs/base/common/codicons';
|
||||
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);
|
||||
export const suggestMoreInfoIcon = registerIcon('suggest-more-info', Codicon.chevronRight, nls.localize('suggestMoreInfoIcon', 'Icon for more information in the suggest widget.'));
|
||||
|
||||
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;
|
||||
const _completionItemColor = new class ColorExtractor {
|
||||
|
||||
function extractColor(item: CompletionItem, out: string[]): boolean {
|
||||
const label = typeof item.completion.label === 'string'
|
||||
? item.completion.label
|
||||
: item.completion.label.name;
|
||||
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');
|
||||
|
||||
if (label.match(colorRegExp)) {
|
||||
out[0] = label;
|
||||
return true;
|
||||
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;
|
||||
}
|
||||
if (typeof item.completion.documentation === 'string' && item.completion.documentation.match(colorRegExp)) {
|
||||
out[0] = item.completion.documentation;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
export interface ISuggestionTemplateData {
|
||||
@@ -116,7 +124,7 @@ export class ItemRenderer implements IListRenderer<CompletionItem, ISuggestionTe
|
||||
data.qualifierLabel = append(data.left, $('span.qualifier-label'));
|
||||
data.detailsLabel = append(data.right, $('span.details-label'));
|
||||
|
||||
data.readMore = append(data.right, $('span.readMore' + suggestMoreInfoIcon.cssSelector));
|
||||
data.readMore = append(data.right, $('span.readMore' + ThemeIcon.asCSSSelector(suggestMoreInfoIcon)));
|
||||
data.readMore.title = nls.localize('readMore', "Read More");
|
||||
|
||||
const configureFont = () => {
|
||||
@@ -165,7 +173,7 @@ export class ItemRenderer implements IListRenderer<CompletionItem, ISuggestionTe
|
||||
};
|
||||
|
||||
let color: string[] = [];
|
||||
if (completion.kind === CompletionItemKind.Color && extractColor(element, color)) {
|
||||
if (completion.kind === CompletionItemKind.Color && _completionItemColor.extract(element, color)) {
|
||||
// special logic for 'color' completion items
|
||||
data.icon.className = 'icon customcolor';
|
||||
data.iconContainer.className = 'icon hide';
|
||||
@@ -214,6 +222,12 @@ export class ItemRenderer implements IListRenderer<CompletionItem, ISuggestionTe
|
||||
data.root.title = `${textLabel}${completion.label.parameters ?? ''} ${completion.label.qualifier ?? ''} ${completion.label.type ?? ''}`;
|
||||
}
|
||||
|
||||
if (this._editor.getOption(EditorOption.suggest).showInlineDetails) {
|
||||
show(data.detailsLabel);
|
||||
} else {
|
||||
hide(data.detailsLabel);
|
||||
}
|
||||
|
||||
if (canExpandCompletionItem(element)) {
|
||||
data.right.classList.add('can-expand-details');
|
||||
show(data.readMore);
|
||||
|
||||
Reference in New Issue
Block a user