File tree 2 files changed +7
-15
lines changed
2 files changed +7
-15
lines changed Original file line number Diff line number Diff line change 1
1
import { fileURLToPath } from "url" ;
2
2
import { RequestMessage } from "vscode-languageserver" ;
3
+ import { CompletionItem } from "vscode-languageserver-protocol" ;
3
4
import * as utils from "./utils" ;
4
5
import * as path from "path" ;
5
6
import { execFileSync } from "child_process" ;
@@ -60,11 +61,11 @@ export function runDumpCommand(msg: RequestMessage): dumpCommandResult | null {
60
61
}
61
62
}
62
63
63
- type completionCommandResult = [ { label : string } ] ;
64
+ // TODO: the result will never be null soon when the updated binary syncs
64
65
export function runCompletionCommand (
65
66
msg : RequestMessage ,
66
67
code : string
67
- ) : completionCommandResult | null {
68
+ ) : CompletionItem [ ] | null {
68
69
let executable = findExecutable ( msg . params . textDocument . uri ) ;
69
70
if ( executable == null ) {
70
71
return null ;
Original file line number Diff line number Diff line change @@ -385,22 +385,13 @@ function onMessage(msg: m.Message) {
385
385
send ( emptyDefinitionResponse ) ;
386
386
}
387
387
} else if ( msg . method === p . CompletionRequest . method ) {
388
- let emptyCompletionResponse : m . ResponseMessage = {
388
+ let code = getOpenedFileContent ( msg . params . textDocument . uri ) ;
389
+ let completionResponse : m . ResponseMessage = {
389
390
jsonrpc : c . jsonrpcVersion ,
390
391
id : msg . id ,
391
- result : null ,
392
+ result : runCompletionCommand ( msg , code ) ,
392
393
} ;
393
- let code = getOpenedFileContent ( msg . params . textDocument . uri ) ;
394
- let result = runCompletionCommand ( msg , code ) ;
395
- if ( result === null ) {
396
- send ( emptyCompletionResponse ) ;
397
- } else {
398
- let definitionResponse : m . ResponseMessage = {
399
- ...emptyCompletionResponse ,
400
- result : result ,
401
- } ;
402
- send ( definitionResponse ) ;
403
- }
394
+ send ( completionResponse ) ;
404
395
} else if ( msg . method === p . DocumentFormattingRequest . method ) {
405
396
// technically, a formatting failure should reply with the error. Sadly
406
397
// the LSP alert box for these error replies sucks (e.g. doesn't actually
You can’t perform that action at this time.
0 commit comments