mirror of
https://github.com/Microsoft/vscode
synced 2024-09-13 21:55:38 +00:00
Save off full ts completion entry
This commit is contained in:
parent
5d99b29558
commit
0a42cc1c8c
|
@ -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
|
||||
]
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in a new issue