@@ -63,13 +63,21 @@ export class GoCompletionItemProvider implements vscode.CompletionItemProvider {
6363 this . globalState = globalState ;
6464 }
6565
66- public provideCompletionItems ( document : vscode . TextDocument , position : vscode . Position , token : vscode . CancellationToken ) : Thenable < vscode . CompletionItem [ ] > {
67- return this . provideCompletionItemsInternal ( document , position , token , vscode . workspace . getConfiguration ( 'go' , document . uri ) ) ;
66+ public provideCompletionItems ( document : vscode . TextDocument , position : vscode . Position , token : vscode . CancellationToken ) : Thenable < vscode . CompletionList > {
67+ return this . provideCompletionItemsInternal ( document , position , token , vscode . workspace . getConfiguration ( 'go' , document . uri ) ) . then ( result => {
68+ if ( ! result ) {
69+ return new vscode . CompletionList ( [ ] , false ) ;
70+ }
71+ if ( Array . isArray ( result ) ) {
72+ return new vscode . CompletionList ( result , false ) ;
73+ }
74+ return result ;
75+ } ) ;
6876 }
6977
70- public provideCompletionItemsInternal ( document : vscode . TextDocument , position : vscode . Position , token : vscode . CancellationToken , config : vscode . WorkspaceConfiguration ) : Thenable < vscode . CompletionItem [ ] > {
78+ public provideCompletionItemsInternal ( document : vscode . TextDocument , position : vscode . Position , token : vscode . CancellationToken , config : vscode . WorkspaceConfiguration ) : Thenable < vscode . CompletionItem [ ] | vscode . CompletionList > {
7179 return this . ensureGoCodeConfigured ( document . uri ) . then ( ( ) => {
72- return new Promise < vscode . CompletionItem [ ] > ( ( resolve , reject ) => {
80+ return new Promise < vscode . CompletionItem [ ] | vscode . CompletionList > ( ( resolve , reject ) => {
7381 let filename = document . fileName ;
7482 let lineText = document . lineAt ( position . line ) . text ;
7583 let lineTillCurrentPosition = lineText . substr ( 0 , position . character ) ;
@@ -161,7 +169,7 @@ export class GoCompletionItemProvider implements vscode.CompletionItemProvider {
161169 } ;
162170 suggestions . push ( item ) ;
163171 } ) ;
164- resolve ( suggestions ) ;
172+ resolve ( new vscode . CompletionList ( suggestions , true ) ) ;
165173 }
166174 }
167175 resolve ( suggestions ) ;
0 commit comments