Skip to content

Commit

Permalink
refactor: inline one off function
Browse files Browse the repository at this point in the history
Signed-off-by: Rudi Grinberg <[email protected]>

ps-id: 2180BF08-5069-4066-B15D-BFB5D3A645D3
  • Loading branch information
rgrinberg committed Feb 23, 2022
1 parent 4e9369c commit 653aada
Showing 1 changed file with 9 additions and 10 deletions.
19 changes: 9 additions & 10 deletions ocaml-lsp-server/src/ocaml_lsp_server.ml
Original file line number Diff line number Diff line change
Expand Up @@ -714,22 +714,21 @@ let definition_query server (state : State.t) uri position merlin_request =
in
None

let await_no_cancel task =
let+ res = Lev_fiber.Thread.await task in
match res with
| Ok s -> s
| Error `Cancelled -> assert false
| Error (`Exn exn) -> Exn_with_backtrace.reraise exn

let workspace_symbol server (state : State.t) (params : WorkspaceSymbolParams.t)
=
let* symbols, errors =
let workspaces = Workspaces.workspace_folders (State.workspaces state) in
let* thread = Lazy_fiber.force state.symbols_thread in
let+ symbols_results =
Lev_fiber.Thread.task thread ~f:(fun () ->
Workspace_symbol.run params workspaces)
>>= await_no_cancel
let* task =
Lev_fiber.Thread.task thread ~f:(fun () ->
Workspace_symbol.run params workspaces)
in
let+ res = Lev_fiber.Thread.await task in
match res with
| Ok s -> s
| Error `Cancelled -> assert false
| Error (`Exn exn) -> Exn_with_backtrace.reraise exn
in
List.partition_map symbols_results ~f:(function
| Ok r -> Left r
Expand Down

0 comments on commit 653aada

Please sign in to comment.