Skip to content

Commit

Permalink
Notify the user when the index is out of date
Browse files Browse the repository at this point in the history
  • Loading branch information
voodoos committed Jan 29, 2024
1 parent ef50a83 commit ba1d99a
Showing 1 changed file with 16 additions and 3 deletions.
19 changes: 16 additions & 3 deletions ocaml-lsp-server/src/ocaml_lsp_server.ml
Original file line number Diff line number Diff line change
Expand Up @@ -427,17 +427,30 @@ let selection_range (state : State.t)
in
List.filter_opt ranges

let references (state : State.t)
let references rpc (state : State.t)
{ ReferenceParams.textDocument = { uri }; position; _ } =
let doc = Document_store.get state.store uri in
match Document.kind doc with
| `Other -> Fiber.return None
| `Merlin doc ->
let+ locs, _desync =
let* locs, desync =
Document.Merlin.dispatch_exn
doc
(Occurrences (`Ident_at (Position.logical position), `Project))
in
let+ () =
if not desync then Fiber.return () else
let msg =
let message =
"The index might be out-of-sync and only local results are shown. \
If you use Dune you can build the target `@ocaml-index` to refresh \
the index."
in
ShowMessageParams.create ~message ~type_:Warning
in
task_if_running state.detached ~f:(fun () ->
Server.notification rpc (ShowMessage msg))
in
Some
(List.map locs ~f:(fun loc ->
let range = Range.of_loc loc in
Expand Down Expand Up @@ -607,7 +620,7 @@ let on_request :
| Some _ | None -> Hover_req.Default
in
later (fun (_ : State.t) () -> Hover_req.handle rpc req mode) ()
| TextDocumentReferences req -> later references req
| TextDocumentReferences req -> later (references rpc) req
| TextDocumentCodeLensResolve codeLens -> now codeLens
| TextDocumentCodeLens req -> (
match state.configuration.data.codelens with
Expand Down

0 comments on commit ba1d99a

Please sign in to comment.