From 0a42cc1c8cd50583c392de3c6243c4edf0e8bbcf Mon Sep 17 00:00:00 2001 From: Matt Bierner Date: Fri, 5 Jan 2018 16:12:43 -0800 Subject: [PATCH] Save off full ts completion entry --- .../src/features/completionItemProvider.ts | 30 +++++++++---------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/extensions/typescript/src/features/completionItemProvider.ts b/extensions/typescript/src/features/completionItemProvider.ts index 775fcb40518..d6aeedd70ba 100644 --- a/extensions/typescript/src/features/completionItemProvider.ts +++ b/extensions/typescript/src/features/completionItemProvider.ts @@ -21,38 +21,37 @@ import { CommandManager, Command } from '../utils/commandManager'; const localize = nls.loadMessageBundle(); class MyCompletionItem extends CompletionItem { - public readonly source: string | undefined; public readonly useCodeSnippet: boolean; constructor( public readonly position: Position, public readonly document: TextDocument, - entry: Proto.CompletionEntry, + public readonly tsEntry: Proto.CompletionEntry, enableDotCompletions: boolean, useCodeSnippetsOnMethodSuggest: boolean ) { - super(entry.name); - this.source = entry.source; + super(tsEntry.name); + this.source = tsEntry.source; - if (entry.isRecommended) { + if (tsEntry.isRecommended) { // Make sure isRecommended property always comes first // https://github.com/Microsoft/vscode/issues/40325 - this.sortText = '\0' + entry.sortText; - } else if (entry.source) { + this.sortText = '\0' + tsEntry.sortText; + } else if (tsEntry.source) { // De-prioritze auto-imports // https://github.com/Microsoft/vscode/issues/40311 - this.sortText = '\uffff' + entry.sortText; + this.sortText = '\uffff' + tsEntry.sortText; } else { - this.sortText = entry.sortText; + this.sortText = tsEntry.sortText; } - this.kind = MyCompletionItem.convertKind(entry.kind); + this.kind = MyCompletionItem.convertKind(tsEntry.kind); this.position = position; - this.commitCharacters = MyCompletionItem.getCommitCharacters(enableDotCompletions, !useCodeSnippetsOnMethodSuggest, entry.kind); + this.commitCharacters = MyCompletionItem.getCommitCharacters(enableDotCompletions, !useCodeSnippetsOnMethodSuggest, tsEntry.kind); this.useCodeSnippet = useCodeSnippetsOnMethodSuggest && (this.kind === CompletionItemKind.Function || this.kind === CompletionItemKind.Method); - if (entry.replacementSpan) { - this.range = tsTextSpanToVsRange(entry.replacementSpan); + if (tsEntry.replacementSpan) { + this.range = tsTextSpanToVsRange(tsEntry.replacementSpan); } } @@ -271,7 +270,8 @@ export default class TypeScriptCompletionItemProvider implements CompletionItemP try { const args: Proto.CompletionsRequestArgs = { ...vsPositionToTsFileLocation(file, position), - includeExternalModuleExports: config.autoImportSuggestions + includeExternalModuleExports: config.autoImportSuggestions, + includeInsertTextCompletions: true }; const msg = await this.client.execute('completions', args, token); // This info has to come from the tsserver. See https://github.com/Microsoft/TypeScript/issues/2831 @@ -342,7 +342,7 @@ export default class TypeScriptCompletionItemProvider implements CompletionItemP const args: Proto.CompletionDetailsRequestArgs = { ...vsPositionToTsFileLocation(filepath, item.position), entryNames: [ - item.source ? { name: item.label, source: item.source } : item.label + item.tsEntry.source ? { name: item.tsEntry.name, source: item.tsEntry.source } : item.tsEntry.name ] };