Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Strikeout deprecated CompletionItems #78092

Merged
merged 12 commits into from
Aug 21, 2019
4 changes: 4 additions & 0 deletions src/vs/editor/common/modes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
4 changes: 4 additions & 0 deletions src/vs/editor/contrib/suggest/media/suggest.css
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
8 changes: 8 additions & 0 deletions src/vs/editor/contrib/suggest/suggestWidget.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,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";
kamranayub marked this conversation as resolved.
Show resolved Hide resolved

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 {
Expand Down Expand Up @@ -195,6 +199,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, '');

Expand Down
4 changes: 4 additions & 0 deletions src/vs/monaco.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4800,6 +4800,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.
Expand Down
11 changes: 9 additions & 2 deletions src/vs/vscode.proposed.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1307,11 +1307,18 @@ declare module 'vscode' {

//#region Deprecated support

export interface CompletionItem {
/**
* Indicates if this item is deprecated.
*/
deprecated?: boolean;
}

export enum DiagnosticTag {
/**
* Deprecated or obsolete code.
* Deprecated or obsolete code
*
* Diagnostics with this tag are rendered with a strike through.
* Can be used to style with strikeout or other "obsolete" styling.
*/
Deprecated = 2,
}
Expand Down
1 change: 1 addition & 0 deletions src/vs/workbench/api/browser/mainThreadLanguageFeatures.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
};
Expand Down
1 change: 1 addition & 0 deletions src/vs/workbench/api/common/extHost.protocol.ts
Original file line number Diff line number Diff line change
Expand Up @@ -941,6 +941,7 @@ export interface SuggestDataDto {
k/* commitCharacters */?: string[];
l/* additionalTextEdits */?: ISingleEditOperation[];
m/* command */?: modes.Command;
n/* deprecated */?: boolean;
// not-standard
x?: ChainedCacheId;
}
Expand Down
1 change: 1 addition & 0 deletions src/vs/workbench/api/common/extHostLanguageFeatures.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down