diff --git a/src/goSuggest.ts b/src/goSuggest.ts index 53edd8a1c..a5d9e664e 100644 --- a/src/goSuggest.ts +++ b/src/goSuggest.ts @@ -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 { - return this.provideCompletionItemsInternal(document, position, token, vscode.workspace.getConfiguration('go', document.uri)); + public provideCompletionItems(document: vscode.TextDocument, position: vscode.Position, token: vscode.CancellationToken): Thenable { + 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 { + public provideCompletionItemsInternal(document: vscode.TextDocument, position: vscode.Position, token: vscode.CancellationToken, config: vscode.WorkspaceConfiguration): Thenable { return this.ensureGoCodeConfigured(document.uri).then(() => { - return new Promise((resolve, reject) => { + return new Promise((resolve, reject) => { let filename = document.fileName; let lineText = document.lineAt(position.line).text; let lineTillCurrentPosition = lineText.substr(0, position.character); @@ -161,7 +169,7 @@ export class GoCompletionItemProvider implements vscode.CompletionItemProvider { }; suggestions.push(item); }); - resolve(suggestions); + resolve(new vscode.CompletionList(suggestions, true)); } } resolve(suggestions);