Merge pull request #78092 from kamranayub/joh/completionsDeprecated

Strikeout deprecated CompletionItems
This commit is contained in:
Johannes Rieken 2019-08-21 11:19:40 +02:00 committed by GitHub
commit 444783451b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 34 additions and 0 deletions

View file

@ -396,6 +396,10 @@ export interface CompletionItem {
* an icon is chosen by the editor.
*/
kind: CompletionItemKind;
/**
* Indicates if this item is deprecated.
*/
deprecated?: boolean;
/**
* A human-readable string with additional information
* about this item, like type or symbol information.

View file

@ -97,6 +97,10 @@
font-weight: bold;
}
.monaco-editor .suggest-widget-deprecated span {
text-decoration: line-through;
}
/** Icon styles **/
.monaco-editor .suggest-widget .details > .monaco-scrollable-element > .body > .header > .close,

View file

@ -60,6 +60,10 @@ export const editorSuggestWidgetForeground = registerColor('editorSuggestWidget.
export const editorSuggestWidgetSelectedBackground = registerColor('editorSuggestWidget.selectedBackground', { dark: listFocusBackground, light: listFocusBackground, hc: listFocusBackground }, nls.localize('editorSuggestWidgetSelectedBackground', 'Background color of the selected entry in the suggest widget.'));
export const editorSuggestWidgetHighlightForeground = registerColor('editorSuggestWidget.highlightForeground', { dark: listHighlightForeground, light: listHighlightForeground, hc: listHighlightForeground }, nls.localize('editorSuggestWidgetHighlightForeground', 'Color of the match highlights in the suggest widget.'));
/**
* Suggest widget styles
*/
const editorSuggestWidgetDeprecatedClassName = 'suggest-widget-deprecated';
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 extractColor(item: CompletionItem, out: string[]): boolean {
@ -193,6 +197,10 @@ class Renderer implements IListRenderer<CompletionItem, ISuggestionTemplateData>
];
}
if (suggestion.label && suggestion.deprecated) {
labelOptions.extraClasses = (labelOptions.extraClasses || []).concat([editorSuggestWidgetDeprecatedClassName]);
}
data.iconLabel.setLabel(suggestion.label, undefined, labelOptions);
data.typeLabel.textContent = (suggestion.detail || '').replace(/\n.*$/m, '');

4
src/vs/monaco.d.ts vendored
View file

@ -4814,6 +4814,10 @@ declare namespace monaco.languages {
* an icon is chosen by the editor.
*/
kind: CompletionItemKind;
/**
* Indicates if this item is deprecated.
*/
deprecated?: boolean;
/**
* A human-readable string with additional information
* about this item, like type or symbol information.

View file

@ -1141,4 +1141,15 @@ declare module 'vscode' {
}
//#endregion
//#region Deprecated support
export interface CompletionItem {
/**
* Indicates if this item is deprecated.
*/
deprecated?: boolean;
}
//#endregion
}

View file

@ -341,6 +341,7 @@ export class MainThreadLanguageFeatures implements MainThreadLanguageFeaturesSha
commitCharacters: data.k,
additionalTextEdits: data.l,
command: data.m,
deprecated: data.n,
// not-standard
_id: data.x,
};

View file

@ -934,6 +934,7 @@ export interface ISuggestDataDto {
k/* commitCharacters */?: string[];
l/* additionalTextEdits */?: ISingleEditOperation[];
m/* command */?: modes.Command;
n/* deprecated */?: boolean;
// not-standard
x?: ChainedCacheId;
}

View file

@ -736,6 +736,7 @@ class SuggestAdapter {
k: item.commitCharacters,
l: item.additionalTextEdits && item.additionalTextEdits.map(typeConvert.TextEdit.from),
m: this._commands.toInternal(item.command, disposables),
n: item.deprecated
};
// 'insertText'-logic