Skip to content

Commit

Permalink
Observe isIncomplete metadata passed by from a plugin
Browse files Browse the repository at this point in the history
Supports cases like microsoft/typescript-styled-plugin#41

Requires TS 3.2
  • Loading branch information
mjbvz committed Nov 10, 2018
1 parent 2683f65 commit a3fa56b
Showing 1 changed file with 7 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -329,9 +329,9 @@ class TypeScriptCompletionItemProvider implements vscode.CompletionItemProvider
position: vscode.Position,
token: vscode.CancellationToken,
context: vscode.CompletionContext
): Promise<vscode.CompletionItem[] | null> {
): Promise<vscode.CompletionList | null> {
if (this.typingsStatus.isAcquiringTypings) {
return Promise.reject<vscode.CompletionItem[]>({
return Promise.reject<vscode.CompletionList>({
label: localize(
{ key: 'acquiringTypingsLabel', comment: ['Typings refers to the *.d.ts typings files that power our IntelliSense. It should not be localized'] },
'Acquiring typings...'),
Expand Down Expand Up @@ -363,13 +363,15 @@ class TypeScriptCompletionItemProvider implements vscode.CompletionItemProvider
};

let isNewIdentifierLocation = true;
let msg: ReadonlyArray<Proto.CompletionEntry> | undefined = undefined;
let isIncomplete = false;
let msg: ReadonlyArray<Proto.CompletionEntry>;
if (this.client.apiVersion.gte(API.v300)) {
const response = await this.client.interuptGetErr(() => this.client.execute('completionInfo', args, token));
if (response.type !== 'response' || !response.body) {
return null;
}
isNewIdentifierLocation = response.body.isNewIdentifierLocation;
isIncomplete = (response as any).metadata && (response as any).metadata.isIncomplete;
msg = response.body.entries;
} else {
const response = await this.client.interuptGetErr(() => this.client.execute('completions', args, token));
Expand All @@ -381,13 +383,14 @@ class TypeScriptCompletionItemProvider implements vscode.CompletionItemProvider
}

const isInValidCommitCharacterContext = this.isInValidCommitCharacterContext(document, position);
return msg
const items = msg
.filter(entry => !shouldExcludeCompletionEntry(entry, completionConfiguration))
.map(entry => new MyCompletionItem(position, document, line.text, entry, completionConfiguration.useCodeSnippetsOnMethodSuggest, {
isNewIdentifierLocation,
isInValidCommitCharacterContext,
enableCallCompletions: !completionConfiguration.useCodeSnippetsOnMethodSuggest
}));
return new vscode.CompletionList(items, isIncomplete);
}

private getTsTriggerCharacter(context: vscode.CompletionContext): Proto.CompletionsTriggerCharacter | undefined {
Expand Down

0 comments on commit a3fa56b

Please sign in to comment.