mirror of
https://github.com/microsoft/vscode.git
synced 2026-04-25 11:08:51 +01:00
@@ -7,6 +7,7 @@ import * as vscode from 'vscode';
|
||||
import * as nls from 'vscode-nls';
|
||||
import { Command, CommandManager } from '../commands/commandManager';
|
||||
import type * as Proto from '../protocol';
|
||||
import protocol = require('../protocol');
|
||||
import * as PConst from '../protocol.const';
|
||||
import { ClientCapability, ITypeScriptServiceClient, ServerResponse } from '../typescriptService';
|
||||
import API from '../utils/api';
|
||||
@@ -134,18 +135,7 @@ class MyCompletionItem extends vscode.CompletionItem {
|
||||
this.kind = vscode.CompletionItemKind.Color;
|
||||
}
|
||||
|
||||
if (tsEntry.kind === PConst.Kind.script) {
|
||||
for (const extModifier of PConst.KindModifiers.fileExtensionKindModifiers) {
|
||||
if (kindModifiers.has(extModifier)) {
|
||||
if (tsEntry.name.toLowerCase().endsWith(extModifier)) {
|
||||
this.detail = tsEntry.name;
|
||||
} else {
|
||||
this.detail = tsEntry.name + extModifier;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
this.detail = getScriptKindDetails(tsEntry);
|
||||
}
|
||||
|
||||
this.resolveRange();
|
||||
@@ -206,7 +196,11 @@ class MyCompletionItem extends vscode.CompletionItem {
|
||||
|
||||
const detail = response.body[0];
|
||||
|
||||
this.detail = this.getDetails(client, detail);
|
||||
const newItemDetails = this.getDetails(client, detail);
|
||||
if (newItemDetails) {
|
||||
this.detail = newItemDetails;
|
||||
}
|
||||
|
||||
this.documentation = this.getDocumentation(client, detail, this.document.uri);
|
||||
|
||||
const codeAction = this.getCodeActions(detail, filepath);
|
||||
@@ -253,6 +247,11 @@ class MyCompletionItem extends vscode.CompletionItem {
|
||||
): string | undefined {
|
||||
const parts: string[] = [];
|
||||
|
||||
if (detail.kind === PConst.Kind.script) {
|
||||
// details were already added
|
||||
return undefined;
|
||||
}
|
||||
|
||||
for (const action of detail.codeActions ?? []) {
|
||||
parts.push(action.description);
|
||||
}
|
||||
@@ -519,6 +518,24 @@ class MyCompletionItem extends vscode.CompletionItem {
|
||||
}
|
||||
}
|
||||
|
||||
function getScriptKindDetails(tsEntry: protocol.CompletionEntry,): string | undefined {
|
||||
if (!tsEntry.kindModifiers || tsEntry.kind !== PConst.Kind.script) {
|
||||
return;
|
||||
}
|
||||
|
||||
const kindModifiers = parseKindModifier(tsEntry.kindModifiers);
|
||||
for (const extModifier of PConst.KindModifiers.fileExtensionKindModifiers) {
|
||||
if (kindModifiers.has(extModifier)) {
|
||||
if (tsEntry.name.toLowerCase().endsWith(extModifier)) {
|
||||
return tsEntry.name;
|
||||
} else {
|
||||
return tsEntry.name + extModifier;
|
||||
}
|
||||
}
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
|
||||
|
||||
class CompletionAcceptedCommand implements Command {
|
||||
public static readonly ID = '_typescript.onCompletionAccepted';
|
||||
|
||||
Reference in New Issue
Block a user