fix possible wrong name for completion detail request

Closes #178
This commit is contained in:
Qiming Zhao 2020-08-08 20:51:18 +08:00
parent 986538f4aa
commit 72a515a635
2 changed files with 4 additions and 7 deletions

View file

@ -218,7 +218,7 @@ export default class TypeScriptCompletionItemProvider implements CompletionItemP
): Promise<CompletionItem> { ): Promise<CompletionItem> {
if (item == null) return undefined if (item == null) return undefined
let { uri, position, source } = item.data let { uri, position, source, name } = item.data
const filepath = this.client.toPath(uri) const filepath = this.client.toPath(uri)
if (!filepath) return undefined if (!filepath) return undefined
let document = workspace.getDocument(uri) let document = workspace.getDocument(uri)
@ -228,11 +228,7 @@ export default class TypeScriptCompletionItemProvider implements CompletionItemP
filepath, filepath,
position position
), ),
entryNames: [ entryNames: [source ? { name, source } : name]
source
? { name: item.label, source }
: item.label
]
} }
let response: ServerResponse.Response<Proto.CompletionDetailsResponse> let response: ServerResponse.Response<Proto.CompletionDetailsResponse>
@ -241,7 +237,7 @@ export default class TypeScriptCompletionItemProvider implements CompletionItemP
} catch { } catch {
return item return item
} }
if (response.type !== 'response' || !response.body) { if (response.type !== 'response' || !response.body || !response.body.length) {
return item return item
} }

View file

@ -100,6 +100,7 @@ export function convertCompletionEntry(
data: { data: {
uri, uri,
position, position,
name: tsEntry.name,
source: tsEntry.source || '' source: tsEntry.source || ''
} }
} }