From 72a515a6351f0dbe4806dd09bc16a4d514ab0bfc Mon Sep 17 00:00:00 2001 From: Qiming Zhao Date: Sat, 8 Aug 2020 20:51:18 +0800 Subject: [PATCH] fix possible wrong name for completion detail request Closes #178 --- src/server/features/completionItemProvider.ts | 10 +++------- src/server/utils/completionItem.ts | 1 + 2 files changed, 4 insertions(+), 7 deletions(-) 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 || '' } }