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
2 changes: 1 addition & 1 deletion src/vs/editor/common/model/intervalTree.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export const enum ClassName {
EditorErrorDecoration = 'squiggly-error',
EditorUnnecessaryDecoration = 'squiggly-unnecessary',
EditorUnnecessaryInlineDecoration = 'squiggly-inline-unnecessary',
EditorDeprecatedInlineDecoration = 'squiggly-inline-deprecated'
EditorDeprecatedInlineDecoration = 'inline-deprecated'
}

export const enum NodeColor {
Expand Down
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
7 changes: 7 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,13 @@
font-weight: bold;
}

.monaco-editor .suggest-widget .monaco-list .monaco-list-row .inline-deprecated {
text-decoration: none; /* override normal inline behavior due to HTML structure */
}
.monaco-editor .suggest-widget .monaco-list .monaco-list-row .inline-deprecated span {
text-decoration: line-through;
}

/** Icon styles **/

.monaco-editor .suggest-widget .details > .monaco-scrollable-element > .body > .header > .close,
Expand Down
5 changes: 5 additions & 0 deletions src/vs/editor/contrib/suggest/suggestWidget.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { createMatches } from 'vs/base/common/filters';
import * as strings from 'vs/base/common/strings';
import { Event, Emitter } from 'vs/base/common/event';
import { onUnexpectedError } from 'vs/base/common/errors';
import { ClassName } from 'vs/editor/common/model/intervalTree';
jrieken marked this conversation as resolved.
Show resolved Hide resolved
import { IDisposable, dispose, toDisposable, DisposableStore, Disposable } from 'vs/base/common/lifecycle';
import { addClass, append, $, hide, removeClass, show, toggleClass, getDomNodePagePosition, hasClass, addDisposableListener } from 'vs/base/browser/dom';
import { IListVirtualDelegate, IListEvent, IListRenderer, IListMouseEvent } from 'vs/base/browser/ui/list/list';
Expand Down Expand Up @@ -195,6 +196,10 @@ class Renderer implements IListRenderer<CompletionItem, ISuggestionTemplateData>
];
}

if (suggestion.label && suggestion.deprecated) {
labelOptions.extraClasses = (labelOptions.extraClasses || []).concat([ClassName.EditorDeprecatedInlineDecoration]);
}

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