Merge from master

This commit is contained in:
Raj Musuku
2019-02-21 17:56:04 -08:00
parent 5a146e34fa
commit 666ae11639
11482 changed files with 119352 additions and 255574 deletions

View File

@@ -3,8 +3,6 @@
* Licensed under the Source EULA. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
'use strict';
import 'vs/css!./media/suggest';
import * as nls from 'vs/nls';
import { createMatches } from 'vs/base/common/filters';
@@ -13,8 +11,7 @@ import { Event, Emitter, chain } from 'vs/base/common/event';
import { onUnexpectedError } from 'vs/base/common/errors';
import { IDisposable, dispose, toDisposable } from 'vs/base/common/lifecycle';
import { addClass, append, $, hide, removeClass, show, toggleClass, getDomNodePagePosition, hasClass } from 'vs/base/browser/dom';
import { HighlightedLabel } from 'vs/base/browser/ui/highlightedlabel/highlightedLabel';
import { IVirtualDelegate, IListEvent, IRenderer } from 'vs/base/browser/ui/list/list';
import { IListVirtualDelegate, IListEvent, IListRenderer } from 'vs/base/browser/ui/list/list';
import { List } from 'vs/base/browser/ui/list/listWidget';
import { DomScrollableElement } from 'vs/base/browser/ui/scrollbar/scrollableElement';
import { IKeybindingService } from 'vs/platform/keybinding/common/keybinding';
@@ -34,8 +31,14 @@ import { IModeService } from 'vs/editor/common/services/modeService';
import { IOpenerService } from 'vs/platform/opener/common/opener';
import { TimeoutTimer, CancelablePromise, createCancelablePromise } from 'vs/base/common/async';
import { CancellationToken } from 'vs/base/common/cancellation';
import { CompletionItemKind, completionKindToCssClass } 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 { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
import { FileKind } from 'vs/platform/files/common/files';
const sticky = false; // for development purposes
const expandSuggestionDocsByDefault = false;
const maxSuggestionsToShow = 12;
@@ -43,7 +46,7 @@ interface ISuggestionTemplateData {
root: HTMLElement;
icon: HTMLElement;
colorspan: HTMLElement;
highlightedLabel: HighlightedLabel;
iconLabel: IconLabel;
typeLabel: HTMLElement;
readMore: HTMLElement;
disposables: IDisposable[];
@@ -75,12 +78,15 @@ function canExpandCompletionItem(item: ICompletionItem) {
return (suggestion.detail && suggestion.detail !== suggestion.label);
}
class Renderer implements IRenderer<ICompletionItem, ISuggestionTemplateData> {
class Renderer implements IListRenderer<ICompletionItem, ISuggestionTemplateData> {
constructor(
private widget: SuggestWidget,
private editor: ICodeEditor,
private triggerKeybindingLabel: string
private triggerKeybindingLabel: string,
@IModelService private readonly _modelService: IModelService,
@IModeService private readonly _modeService: IModeService,
@IThemeService private readonly _themeService: IThemeService,
) {
}
@@ -93,14 +99,17 @@ class Renderer implements IRenderer<ICompletionItem, ISuggestionTemplateData> {
const data = <ISuggestionTemplateData>Object.create(null);
data.disposables = [];
data.root = container;
addClass(data.root, 'show-file-icons');
data.icon = append(container, $('.icon'));
data.colorspan = append(data.icon, $('span.colorspan'));
const text = append(container, $('.contents'));
const main = append(text, $('.main'));
data.highlightedLabel = new HighlightedLabel(main);
data.disposables.push(data.highlightedLabel);
data.iconLabel = new IconLabel(main, { supportHighlights: true });
data.disposables.push(data.iconLabel);
data.typeLabel = append(main, $('span.type-label'));
data.readMore = append(main, $('span.readMore'));
@@ -111,10 +120,12 @@ class Renderer implements IRenderer<ICompletionItem, ISuggestionTemplateData> {
const fontFamily = configuration.fontInfo.fontFamily;
const fontSize = configuration.contribInfo.suggestFontSize || configuration.fontInfo.fontSize;
const lineHeight = configuration.contribInfo.suggestLineHeight || configuration.fontInfo.lineHeight;
const fontWeight = configuration.fontInfo.fontWeight;
const fontSizePx = `${fontSize}px`;
const lineHeightPx = `${lineHeight}px`;
data.root.style.fontSize = fontSizePx;
data.root.style.fontWeight = fontWeight;
main.style.fontFamily = fontFamily;
main.style.lineHeight = lineHeightPx;
data.icon.style.height = lineHeightPx;
@@ -132,29 +143,49 @@ class Renderer implements IRenderer<ICompletionItem, ISuggestionTemplateData> {
return data;
}
renderElement(element: ICompletionItem, index: number, templateData: ISuggestionTemplateData): void {
renderElement(element: ICompletionItem, _index: number, templateData: ISuggestionTemplateData): void {
const data = <ISuggestionTemplateData>templateData;
const suggestion = (<ICompletionItem>element).suggestion;
if (canExpandCompletionItem(element)) {
data.root.setAttribute('aria-label', nls.localize('suggestionWithDetailsAriaLabel', "{0}, suggestion, has details", suggestion.label));
} else {
data.root.setAttribute('aria-label', nls.localize('suggestionAriaLabel', "{0}, suggestion", suggestion.label));
}
data.icon.className = 'icon ' + suggestion.type;
data.icon.className = 'icon ' + completionKindToCssClass(suggestion.kind);
data.colorspan.style.backgroundColor = '';
if (suggestion.type === 'color') {
let color = matchesColor(suggestion.label) || typeof suggestion.documentation === 'string' && matchesColor(suggestion.documentation);
if (color) {
data.icon.className = 'icon customcolor';
data.colorspan.style.backgroundColor = color;
}
const labelOptions: IIconLabelValueOptions = {
labelEscapeNewLines: true,
matches: createMatches(element.matches)
};
let color: string;
if (suggestion.kind === CompletionItemKind.Color && (color = matchesColor(suggestion.label) || typeof suggestion.documentation === 'string' && matchesColor(suggestion.documentation))) {
// special logic for 'color' completion items
data.icon.className = 'icon customcolor';
data.colorspan.style.backgroundColor = color;
} else if (suggestion.kind === CompletionItemKind.File && this._themeService.getIconTheme().hasFileIcons) {
// special logic for 'file' completion items
data.icon.className = 'icon hide';
labelOptions.extraClasses = [].concat(
getIconClasses(this._modelService, this._modeService, URI.from({ scheme: 'fake', path: suggestion.label }), FileKind.FILE),
getIconClasses(this._modelService, this._modeService, URI.from({ scheme: 'fake', path: suggestion.detail }), FileKind.FILE)
);
} else if (suggestion.kind === CompletionItemKind.Folder && this._themeService.getIconTheme().hasFolderIcons) {
// special logic for 'folder' completion items
data.icon.className = 'icon hide';
labelOptions.extraClasses = [].concat(
getIconClasses(this._modelService, this._modeService, URI.from({ scheme: 'fake', path: suggestion.label }), FileKind.FOLDER),
getIconClasses(this._modelService, this._modeService, URI.from({ scheme: 'fake', path: suggestion.detail }), FileKind.FOLDER)
);
} else {
// normal icon
data.icon.className = 'icon hide';
labelOptions.extraClasses = [
`suggest-icon ${completionKindToCssClass(suggestion.kind)}`
];
}
data.highlightedLabel.set(suggestion.label, createMatches(element.matches), '', true);
// data.highlightedLabel.set(`${suggestion.label} <${element.score}=score(${element.word}, ${suggestion.filterText || suggestion.label})>`, createMatches(element.matches));
data.iconLabel.setValue(suggestion.label, undefined, labelOptions);
data.typeLabel.textContent = (suggestion.detail || '').replace(/\n.*$/m, '');
if (canExpandCompletionItem(element)) {
@@ -181,8 +212,8 @@ class Renderer implements IRenderer<ICompletionItem, ISuggestionTemplateData> {
disposeTemplate(templateData: ISuggestionTemplateData): void {
// {{SQL CARBON EDIT}}
if (templateData.highlightedLabel) {
templateData.highlightedLabel.dispose();
if (templateData.iconLabel) {
templateData.iconLabel.dispose();
}
// {{SQL CARBON EDIT}}
if (templateData.disposables) {
@@ -298,7 +329,10 @@ class SuggestionDetails {
this.body.scrollTop = 0;
this.scrollbar.scanDomNode();
this.ariaLabel = strings.format('{0}\n{1}\n{2}', item.suggestion.label || '', item.suggestion.detail || '', item.suggestion.documentation || '');
this.ariaLabel = strings.format(
'{0}{1}',
item.suggestion.detail || '',
item.suggestion.documentation ? (typeof item.suggestion.documentation === 'string' ? item.suggestion.documentation : item.suggestion.documentation.value) : '');
}
getAriaLabel(): string {
@@ -338,10 +372,12 @@ class SuggestionDetails {
const fontFamily = configuration.fontInfo.fontFamily;
const fontSize = configuration.contribInfo.suggestFontSize || configuration.fontInfo.fontSize;
const lineHeight = configuration.contribInfo.suggestLineHeight || configuration.fontInfo.lineHeight;
const fontWeight = configuration.fontInfo.fontWeight;
const fontSizePx = `${fontSize}px`;
const lineHeightPx = `${lineHeight}px`;
this.el.style.fontSize = fontSizePx;
this.el.style.fontWeight = fontWeight;
this.type.style.fontFamily = fontFamily;
this.close.style.height = lineHeightPx;
this.close.style.width = lineHeightPx;
@@ -359,7 +395,7 @@ export interface ISelectedSuggestion {
model: CompletionModel;
}
export class SuggestWidget implements IContentWidget, IVirtualDelegate<ICompletionItem>, IDisposable {
export class SuggestWidget implements IContentWidget, IListVirtualDelegate<ICompletionItem>, IDisposable {
private static readonly ID: string = 'editor.widget.suggestWidget';
@@ -371,7 +407,7 @@ export class SuggestWidget implements IContentWidget, IVirtualDelegate<ICompleti
private state: State;
private isAuto: boolean;
private loadingTimeout: number;
private loadingTimeout: any;
private currentSuggestionDetails: CancelablePromise<void>;
private focusedItem: ICompletionItem;
private ignoreFocusEvents = false;
@@ -386,7 +422,6 @@ export class SuggestWidget implements IContentWidget, IVirtualDelegate<ICompleti
private suggestWidgetVisible: IContextKey<boolean>;
private suggestWidgetMultipleSuggestions: IContextKey<boolean>;
private suggestionSupportsAutoAccept: IContextKey<boolean>;
private readonly editorBlurTimeout = new TimeoutTimer();
private readonly showTimeout = new TimeoutTimer();
@@ -409,11 +444,11 @@ export class SuggestWidget implements IContentWidget, IVirtualDelegate<ICompleti
private detailsFocusBorderColor: string;
private detailsBorderColor: string;
private storageServiceAvailable: boolean = true;
private expandSuggestionDocs: boolean = false;
private firstFocusInCurrentList: boolean = false;
private preferDocPositionTop: boolean = false;
private docsPositionPreviousWidgetY: number;
constructor(
private editor: ICodeEditor,
@ITelemetryService private telemetryService: ITelemetryService,
@@ -422,7 +457,8 @@ export class SuggestWidget implements IContentWidget, IVirtualDelegate<ICompleti
@IStorageService storageService: IStorageService,
@IKeybindingService keybindingService: IKeybindingService,
@IModeService modeService: IModeService,
@IOpenerService openerService: IOpenerService
@IOpenerService openerService: IOpenerService,
@IInstantiationService instantiationService: IInstantiationService,
) {
const kb = keybindingService.lookupKeybinding('editor.action.triggerSuggest');
const triggerKeybindingLabel = !kb ? '' : ` (${kb.getLabel()})`;
@@ -432,13 +468,6 @@ export class SuggestWidget implements IContentWidget, IVirtualDelegate<ICompleti
this.focusedItem = null;
this.storageService = storageService;
if (this.expandDocsSettingFromStorage() === undefined) {
this.storageService.store('expandSuggestionDocs', expandSuggestionDocsByDefault, StorageScope.GLOBAL);
if (this.expandDocsSettingFromStorage() === undefined) {
this.storageServiceAvailable = false;
}
}
this.element = $('.editor-widget.suggest-widget');
if (!this.editor.getConfiguration().contribInfo.iconsInSuggestions) {
addClass(this.element, 'no-icons');
@@ -448,7 +477,7 @@ export class SuggestWidget implements IContentWidget, IVirtualDelegate<ICompleti
this.listElement = append(this.element, $('.tree'));
this.details = new SuggestionDetails(this.element, this, this.editor, markdownRenderer, triggerKeybindingLabel);
let renderer = new Renderer(this, this.editor, triggerKeybindingLabel);
let renderer = instantiationService.createInstance(Renderer, this, this.editor, triggerKeybindingLabel);
this.list = new List(this.listElement, this, [renderer], {
useShadows: false,
@@ -463,7 +492,6 @@ export class SuggestWidget implements IContentWidget, IVirtualDelegate<ICompleti
listInactiveFocusOutline: activeContrastBorder
}),
themeService.onThemeChange(t => this.onThemeChange(t)),
editor.onDidBlurEditorText(() => this.onEditorBlur()),
editor.onDidLayoutChange(() => this.onEditorLayoutChange()),
this.list.onSelectionChange(e => this.onListSelection(e)),
this.list.onFocusChange(e => this.onListFocus(e)),
@@ -472,7 +500,6 @@ export class SuggestWidget implements IContentWidget, IVirtualDelegate<ICompleti
this.suggestWidgetVisible = SuggestContext.Visible.bindTo(contextKeyService);
this.suggestWidgetMultipleSuggestions = SuggestContext.MultipleSuggestions.bindTo(contextKeyService);
this.suggestionSupportsAutoAccept = SuggestContext.AcceptOnKey.bindTo(contextKeyService);
this.editor.addContentWidget(this);
this.setState(State.Hidden);
@@ -488,18 +515,6 @@ export class SuggestWidget implements IContentWidget, IVirtualDelegate<ICompleti
this.editor.layoutContentWidget(this);
}
private onEditorBlur(): void {
if (sticky) {
return;
}
this.editorBlurTimeout.cancelAndSet(() => {
if (!this.editor.hasTextFocus()) {
this.setState(State.Hidden);
}
}, 150);
}
private onEditorLayoutChange(): void {
if ((this.state === State.Open || this.state === State.Details) && this.expandDocsSettingFromStorage()) {
this.expandSideOrBelow();
@@ -521,10 +536,17 @@ export class SuggestWidget implements IContentWidget, IVirtualDelegate<ICompleti
}
private _getSuggestionAriaAlertLabel(item: ICompletionItem): string {
if (canExpandCompletionItem(item)) {
return nls.localize('ariaCurrentSuggestionWithDetails', "{0}, suggestion, has details", item.suggestion.label);
const isSnippet = item.suggestion.kind === CompletionItemKind.Snippet;
if (!canExpandCompletionItem(item)) {
return isSnippet ? nls.localize('ariaCurrentSnippetSuggestion', "{0}, snippet suggestion", item.suggestion.label)
: nls.localize('ariaCurrentSuggestion', "{0}, suggestion", item.suggestion.label);
} else if (this.expandDocsSettingFromStorage()) {
return isSnippet ? nls.localize('ariaCurrentSnippeSuggestionReadDetails', "{0}, snippet suggestion. Reading details. {1}", item.suggestion.label, this.details.getAriaLabel())
: nls.localize('ariaCurrenttSuggestionReadDetails', "{0}, suggestion. Reading details. {1}", item.suggestion.label, this.details.getAriaLabel());
} else {
return nls.localize('ariaCurrentSuggestion', "{0}, suggestion", item.suggestion.label);
return isSnippet ? nls.localize('ariaCurrentSnippetSuggestionWithDetails', "{0}, snippet suggestion, has details", item.suggestion.label)
: nls.localize('ariaCurrentSuggestionWithDetails', "{0}, suggestion, has details", item.suggestion.label);
}
}
@@ -540,20 +562,20 @@ export class SuggestWidget implements IContentWidget, IVirtualDelegate<ICompleti
}
private onThemeChange(theme: ITheme) {
let backgroundColor = theme.getColor(editorSuggestWidgetBackground);
const backgroundColor = theme.getColor(editorSuggestWidgetBackground);
if (backgroundColor) {
this.listElement.style.backgroundColor = backgroundColor.toString();
this.details.element.style.backgroundColor = backgroundColor.toString();
this.messageElement.style.backgroundColor = backgroundColor.toString();
}
let borderColor = theme.getColor(editorSuggestWidgetBorder);
const borderColor = theme.getColor(editorSuggestWidgetBorder);
if (borderColor) {
this.listElement.style.borderColor = borderColor.toString();
this.details.element.style.borderColor = borderColor.toString();
this.messageElement.style.borderColor = borderColor.toString();
this.detailsBorderColor = borderColor.toString();
}
let focusBorderColor = theme.getColor(focusBorder);
const focusBorderColor = theme.getColor(focusBorder);
if (focusBorderColor) {
this.detailsFocusBorderColor = focusBorderColor.toString();
}
@@ -577,45 +599,47 @@ export class SuggestWidget implements IContentWidget, IVirtualDelegate<ICompleti
}
const item = e.elements[0];
this._ariaAlert(this._getSuggestionAriaAlertLabel(item));
this.firstFocusInCurrentList = !this.focusedItem;
if (item === this.focusedItem) {
return;
}
if (this.currentSuggestionDetails) {
this.currentSuggestionDetails.cancel();
this.currentSuggestionDetails = null;
}
const index = e.indexes[0];
this.suggestionSupportsAutoAccept.set(!item.suggestion.noAutoAccept);
this.firstFocusInCurrentList = !this.focusedItem;
if (item !== this.focusedItem) {
this.focusedItem = item;
this.list.reveal(index);
this.currentSuggestionDetails = createCancelablePromise(token => item.resolve(token));
this.currentSuggestionDetails.then(() => {
// item can have extra information, so re-render
this.ignoreFocusEvents = true;
this.list.splice(index, 1, [item]);
this.list.setFocus([index]);
this.ignoreFocusEvents = false;
if (this.expandDocsSettingFromStorage()) {
this.showDetails();
} else {
removeClass(this.element, 'docs-side');
}
}).catch(onUnexpectedError).then(() => {
if (this.focusedItem === item) {
if (this.currentSuggestionDetails) {
this.currentSuggestionDetails.cancel();
this.currentSuggestionDetails = null;
}
});
this.focusedItem = item;
this.list.reveal(index);
this.currentSuggestionDetails = createCancelablePromise(token => item.resolve(token));
this.currentSuggestionDetails.then(() => {
if (this.list.length < index) {
return;
}
// item can have extra information, so re-render
this.ignoreFocusEvents = true;
this.list.splice(index, 1, [item]);
this.list.setFocus([index]);
this.ignoreFocusEvents = false;
if (this.expandDocsSettingFromStorage()) {
this.showDetails();
} else {
removeClass(this.element, 'docs-side');
}
this._ariaAlert(this._getSuggestionAriaAlertLabel(item));
}).catch(onUnexpectedError).then(() => {
if (this.focusedItem === item) {
this.currentSuggestionDetails = null;
}
});
}
// emit an event
this.onDidFocusEmitter.fire({ item, index, model: this.completionModel });
@@ -676,7 +700,7 @@ export class SuggestWidget implements IContentWidget, IVirtualDelegate<ICompleti
}
}
showTriggered(auto: boolean) {
showTriggered(auto: boolean, delay: number) {
if (this.state !== State.Hidden) {
return;
}
@@ -687,16 +711,24 @@ export class SuggestWidget implements IContentWidget, IVirtualDelegate<ICompleti
this.loadingTimeout = setTimeout(() => {
this.loadingTimeout = null;
this.setState(State.Loading);
}, 50);
}, delay);
}
}
showSuggestions(completionModel: CompletionModel, selectionIndex: number, isFrozen: boolean, isAuto: boolean): void {
this.preferDocPositionTop = false;
this.docsPositionPreviousWidgetY = null;
if (this.loadingTimeout) {
clearTimeout(this.loadingTimeout);
this.loadingTimeout = null;
}
if (this.currentSuggestionDetails) {
this.currentSuggestionDetails.cancel();
this.currentSuggestionDetails = null;
}
if (this.completionModel !== completionModel) {
this.completionModel = completionModel;
}
@@ -721,19 +753,23 @@ export class SuggestWidget implements IContentWidget, IVirtualDelegate<ICompleti
this.completionModel = null;
} else {
const { stats } = this.completionModel;
stats['wasAutomaticallyTriggered'] = !!isAuto;
/* __GDPR__
"suggestWidget" : {
"wasAutomaticallyTriggered" : { "classification": "SystemMetaData", "purpose": "FeatureInsight", "isMeasurement": true },
"${include}": [
"${ICompletionStats}",
"${EditorTelemetryData}"
]
}
*/
this.telemetryService.publicLog('suggestWidget', { ...stats, ...this.editor.getTelemetryData() });
if (this.state !== State.Open) {
const { stats } = this.completionModel;
stats['wasAutomaticallyTriggered'] = !!isAuto;
/* __GDPR__
"suggestWidget" : {
"wasAutomaticallyTriggered" : { "classification": "SystemMetaData", "purpose": "FeatureInsight", "isMeasurement": true },
"${include}": [
"${ICompletionStats}",
"${EditorTelemetryData}"
]
}
*/
this.telemetryService.publicLog('suggestWidget', { ...stats, ...this.editor.getTelemetryData() });
}
this.focusedItem = null;
this.list.splice(0, this.list.length, this.completionModel.items);
if (isFrozen) {
@@ -742,7 +778,7 @@ export class SuggestWidget implements IContentWidget, IVirtualDelegate<ICompleti
this.setState(State.Open);
}
this.list.reveal(selectionIndex, selectionIndex);
this.list.reveal(selectionIndex, 0);
this.list.setFocus([selectionIndex]);
// Reset focus border
@@ -898,6 +934,7 @@ export class SuggestWidget implements IContentWidget, IVirtualDelegate<ICompleti
this.updateExpandDocsSetting(true);
this.showDetails();
this._ariaAlert(this.details.getAriaLabel());
/* __GDPR__
"suggestWidget:expandDetails" : {
"${include}": [
@@ -926,8 +963,6 @@ export class SuggestWidget implements IContentWidget, IVirtualDelegate<ICompleti
this.adjustDocsPosition();
this.editor.focus();
this._ariaAlert(this.details.getAriaLabel());
}
private show(): void {
@@ -962,9 +997,14 @@ export class SuggestWidget implements IContentWidget, IVirtualDelegate<ICompleti
return null;
}
let preference = [ContentWidgetPositionPreference.BELOW, ContentWidgetPositionPreference.ABOVE];
if (this.preferDocPositionTop) {
preference = [ContentWidgetPositionPreference.ABOVE];
}
return {
position: this.editor.getPosition(),
preference: [ContentWidgetPositionPreference.BELOW, ContentWidgetPositionPreference.ABOVE]
preference: preference
};
}
@@ -992,6 +1032,9 @@ export class SuggestWidget implements IContentWidget, IVirtualDelegate<ICompleti
return height;
}
/**
* Adds the propert classes, margins when positioning the docs to the side
*/
private adjustDocsPosition() {
const lineHeight = this.editor.getConfiguration().fontInfo.lineHeight;
const cursorCoords = this.editor.getScrolledVisiblePosition(this.editor.getPosition());
@@ -1002,6 +1045,17 @@ export class SuggestWidget implements IContentWidget, IVirtualDelegate<ICompleti
const widgetX = widgetCoords.left;
const widgetY = widgetCoords.top;
// Fixes #27649
// Check if the Y changed to the top of the cursor and keep the widget flagged to prefer top
if (this.docsPositionPreviousWidgetY &&
this.docsPositionPreviousWidgetY < widgetY &&
!this.preferDocPositionTop) {
this.preferDocPositionTop = true;
this.adjustDocsPosition();
return;
}
this.docsPositionPreviousWidgetY = widgetY;
if (widgetX < cursorX - this.listWidth) {
// Widget is too far to the left of cursor, swap list and docs
addClass(this.element, 'list-right');
@@ -1022,6 +1076,9 @@ export class SuggestWidget implements IContentWidget, IVirtualDelegate<ICompleti
}
}
/**
* Adds the proper classes for positioning the docs to the side or below
*/
private expandSideOrBelow() {
if (!canExpandCompletionItem(this.focusedItem) && this.firstFocusInCurrentList) {
removeClass(this.element, 'docs-side');
@@ -1060,27 +1117,16 @@ export class SuggestWidget implements IContentWidget, IVirtualDelegate<ICompleti
return 'suggestion';
}
// Monaco Editor does not have a storage service
private expandDocsSettingFromStorage(): boolean {
if (this.storageServiceAvailable) {
return this.storageService.getBoolean('expandSuggestionDocs', StorageScope.GLOBAL);
} else {
return this.expandSuggestionDocs;
}
return this.storageService.getBoolean('expandSuggestionDocs', StorageScope.GLOBAL, expandSuggestionDocsByDefault);
}
// Monaco Editor does not have a storage service
private updateExpandDocsSetting(value: boolean) {
if (this.storageServiceAvailable) {
this.storageService.store('expandSuggestionDocs', value, StorageScope.GLOBAL);
} else {
this.expandSuggestionDocs = value;
}
this.storageService.store('expandSuggestionDocs', value, StorageScope.GLOBAL);
}
dispose(): void {
this.state = null;
this.suggestionSupportsAutoAccept = null;
this.currentSuggestionDetails = null;
this.focusedItem = null;
this.element = null;
@@ -1102,11 +1148,11 @@ export class SuggestWidget implements IContentWidget, IVirtualDelegate<ICompleti
}
registerThemingParticipant((theme, collector) => {
let matchHighlight = theme.getColor(editorSuggestWidgetHighlightForeground);
const matchHighlight = theme.getColor(editorSuggestWidgetHighlightForeground);
if (matchHighlight) {
collector.addRule(`.monaco-editor .suggest-widget .monaco-list .monaco-list-row .monaco-highlighted-label .highlight { color: ${matchHighlight}; }`);
}
let foreground = theme.getColor(editorSuggestWidgetForeground);
const foreground = theme.getColor(editorSuggestWidgetForeground);
if (foreground) {
collector.addRule(`.monaco-editor .suggest-widget { color: ${foreground}; }`);
}
@@ -1116,7 +1162,7 @@ registerThemingParticipant((theme, collector) => {
collector.addRule(`.monaco-editor .suggest-widget a { color: ${link}; }`);
}
let codeBackground = theme.getColor(textCodeBlockBackground);
const codeBackground = theme.getColor(textCodeBlockBackground);
if (codeBackground) {
collector.addRule(`.monaco-editor .suggest-widget code { background-color: ${codeBackground}; }`);
}