diff --git a/src/server/features/completionItemProvider.ts b/src/server/features/completionItemProvider.ts index 3bf49c1..9c06b98 100644 --- a/src/server/features/completionItemProvider.ts +++ b/src/server/features/completionItemProvider.ts @@ -218,7 +218,7 @@ export default class TypeScriptCompletionItemProvider implements CompletionItemP ): Promise { if (item == null) return undefined - let { uri, position, source } = item.data + let { uri, position, source, name } = item.data const filepath = this.client.toPath(uri) if (!filepath) return undefined let document = workspace.getDocument(uri) @@ -228,11 +228,7 @@ export default class TypeScriptCompletionItemProvider implements CompletionItemP filepath, position ), - entryNames: [ - source - ? { name: item.label, source } - : item.label - ] + entryNames: [source ? { name, source } : name] } let response: ServerResponse.Response @@ -241,7 +237,7 @@ export default class TypeScriptCompletionItemProvider implements CompletionItemP } catch { return item } - if (response.type !== 'response' || !response.body) { + if (response.type !== 'response' || !response.body || !response.body.length) { return item } diff --git a/src/server/utils/completionItem.ts b/src/server/utils/completionItem.ts index 5aa9314..b6b3ef3 100644 --- a/src/server/utils/completionItem.ts +++ b/src/server/utils/completionItem.ts @@ -100,6 +100,7 @@ export function convertCompletionEntry( data: { uri, position, + name: tsEntry.name, source: tsEntry.source || '' } }