Skip to content
This repository has been archived by the owner on Jul 15, 2023. It is now read-only.

Commit

Permalink
Fix for bug #2011
Browse files Browse the repository at this point in the history
  • Loading branch information
ramya-rao-a committed Oct 16, 2018
1 parent 6952be8 commit d789de0
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions src/goSuggest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,13 +63,21 @@ export class GoCompletionItemProvider implements vscode.CompletionItemProvider {
this.globalState = globalState;
}

public provideCompletionItems(document: vscode.TextDocument, position: vscode.Position, token: vscode.CancellationToken): Thenable<vscode.CompletionItem[]> {
return this.provideCompletionItemsInternal(document, position, token, vscode.workspace.getConfiguration('go', document.uri));
public provideCompletionItems(document: vscode.TextDocument, position: vscode.Position, token: vscode.CancellationToken): Thenable<vscode.CompletionList> {
return this.provideCompletionItemsInternal(document, position, token, vscode.workspace.getConfiguration('go', document.uri)).then(result => {
if (!result) {
return new vscode.CompletionList([], false);
}
if (Array.isArray(result)) {
return new vscode.CompletionList(result, false);
}
return result;
});
}

public provideCompletionItemsInternal(document: vscode.TextDocument, position: vscode.Position, token: vscode.CancellationToken, config: vscode.WorkspaceConfiguration): Thenable<vscode.CompletionItem[]> {
public provideCompletionItemsInternal(document: vscode.TextDocument, position: vscode.Position, token: vscode.CancellationToken, config: vscode.WorkspaceConfiguration): Thenable<vscode.CompletionItem[] | vscode.CompletionList> {
return this.ensureGoCodeConfigured(document.uri).then(() => {
return new Promise<vscode.CompletionItem[]>((resolve, reject) => {
return new Promise<vscode.CompletionItem[] | vscode.CompletionList>((resolve, reject) => {
let filename = document.fileName;
let lineText = document.lineAt(position.line).text;
let lineTillCurrentPosition = lineText.substr(0, position.character);
Expand Down Expand Up @@ -161,7 +169,7 @@ export class GoCompletionItemProvider implements vscode.CompletionItemProvider {
};
suggestions.push(item);
});
resolve(suggestions);
resolve(new vscode.CompletionList(suggestions, true));
}
}
resolve(suggestions);
Expand Down

0 comments on commit d789de0

Please sign in to comment.