Skip to content

Commit

Permalink
Fallback to use insert text when label is falsy (#184944)
Browse files Browse the repository at this point in the history
For #184812
  • Loading branch information
mjbvz committed Jun 12, 2023
1 parent 23fe766 commit ab8ed4b
Showing 1 changed file with 5 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,8 @@ class MyCompletionItem extends vscode.CompletionItem {
public readonly metadata: any | undefined,
client: ITypeScriptServiceClient,
) {
super(tsEntry.name, MyCompletionItem.convertKind(tsEntry.kind));
const label = tsEntry.name || (tsEntry.insertText ?? '');
super(label, MyCompletionItem.convertKind(tsEntry.kind));

if (tsEntry.source && tsEntry.hasAction && client.apiVersion.lt(API.v490)) {
// De-prioritze auto-imports
Expand All @@ -72,18 +73,18 @@ class MyCompletionItem extends vscode.CompletionItem {
// Render "fancy" when source is a workspace path
const qualifierCandidate = vscode.workspace.asRelativePath(tsEntry.source);
if (qualifierCandidate !== tsEntry.source) {
this.label = { label: tsEntry.name, description: qualifierCandidate };
this.label = { label, description: qualifierCandidate };
}

}

const { sourceDisplay, isSnippet } = tsEntry;
if (sourceDisplay) {
this.label = { label: tsEntry.name, description: Previewer.asPlainTextWithLinks(sourceDisplay, client) };
this.label = { label, description: Previewer.asPlainTextWithLinks(sourceDisplay, client) };
}

if (tsEntry.labelDetails) {
this.label = { label: tsEntry.name, ...tsEntry.labelDetails };
this.label = { label, ...tsEntry.labelDetails };
}

this.preselect = tsEntry.isRecommended;
Expand Down

0 comments on commit ab8ed4b

Please sign in to comment.