@@ -63,13 +63,21 @@ export class GoCompletionItemProvider implements vscode.CompletionItemProvider {
63
63
this . globalState = globalState ;
64
64
}
65
65
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
+ } ) ;
68
76
}
69
77
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 > {
71
79
return this . ensureGoCodeConfigured ( document . uri ) . then ( ( ) => {
72
- return new Promise < vscode . CompletionItem [ ] > ( ( resolve , reject ) => {
80
+ return new Promise < vscode . CompletionItem [ ] | vscode . CompletionList > ( ( resolve , reject ) => {
73
81
let filename = document . fileName ;
74
82
let lineText = document . lineAt ( position . line ) . text ;
75
83
let lineTillCurrentPosition = lineText . substr ( 0 , position . character ) ;
@@ -161,7 +169,7 @@ export class GoCompletionItemProvider implements vscode.CompletionItemProvider {
161
169
} ;
162
170
suggestions . push ( item ) ;
163
171
} ) ;
164
- resolve ( suggestions ) ;
172
+ resolve ( new vscode . CompletionList ( suggestions , true ) ) ;
165
173
}
166
174
}
167
175
resolve ( suggestions ) ;
0 commit comments