Skip to content

Commit fcfffbc

Browse files
Return empty completions rather than error
1 parent b1f3179 commit fcfffbc

File tree

3 files changed

+10
-11
lines changed

3 files changed

+10
-11
lines changed

language-server/dm/documentManager.ml

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -667,13 +667,17 @@ let get_context st pos = context_of_id st (id_of_pos st pos)
667667

668668
let get_completions st pos =
669669
match id_of_pos st pos with
670-
| None -> Error ("Can't get completions, no sentence found before the cursor")
670+
| None ->
671+
log ("Can't get completions, no sentence found before the cursor");
672+
[]
671673
| Some id ->
672674
let ost = ExecutionManager.get_vernac_state st.execution_state id in
673675
let settings = ExecutionManager.get_options () in
674676
match Option.bind ost @@ CompletionSuggester.get_completions settings.completion_options with
675-
| None -> Error ("Can't get completions")
676-
| Some lemmas -> Ok (lemmas)
677+
| None ->
678+
log "No completions available";
679+
[]
680+
| Some lemmas -> lemmas
677681

678682
[%%if coq = "8.18" || coq = "8.19"]
679683
[%%elif coq = "8.20"]

language-server/dm/documentManager.mli

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ val all_diagnostics : state -> Diagnostic.t list
118118

119119
val get_proof : state -> Settings.Goals.Diff.Mode.t -> sentence_id option -> ProofState.t option
120120

121-
val get_completions : state -> Position.t -> (completion_item list, string) Result.t
121+
val get_completions : state -> Position.t -> completion_item list
122122

123123
val handle_event : event -> state -> block:bool -> Settings.Mode.t -> Settings.Goals.Diff.Mode.t -> handled_event
124124
(** handles events and returns a new state if it was updated. On top of the next events, it also returns info

language-server/vscoqtop/lspManager.ml

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -458,13 +458,8 @@ let textDocumentCompletion id params =
458458
match Hashtbl.find_opt states (DocumentUri.to_path uri) with
459459
| None -> log @@ "[textDocumentCompletion]ignoring event on non existent document"; Error( {message="Document does not exist"; code=None} ), []
460460
| Some { st } ->
461-
match Dm.DocumentManager.get_completions st position with
462-
| Ok completionItems ->
463-
let items = List.mapi make_CompletionItem completionItems in
464-
return_completion ~isIncomplete:false ~items, []
465-
| Error e ->
466-
let message = e in
467-
Error {message; code=None}, []
461+
let items = List.mapi make_CompletionItem (Dm.DocumentManager.get_completions st position) in
462+
return_completion ~isIncomplete:false ~items, []
468463

469464
let documentSymbol id params =
470465
let Lsp.Types.DocumentSymbolParams.{ textDocument = {uri}; partialResultToken; workDoneToken } = params in (*TODO: At some point we might get ssupport for partialResult and workDone*)

0 commit comments

Comments
 (0)