From 653aada95c57aa0c74b038326d537c7a54c69c9f Mon Sep 17 00:00:00 2001 From: Rudi Grinberg Date: Tue, 22 Feb 2022 20:02:41 -0700 Subject: [PATCH] refactor: inline one off function Signed-off-by: Rudi Grinberg ps-id: 2180BF08-5069-4066-B15D-BFB5D3A645D3 --- ocaml-lsp-server/src/ocaml_lsp_server.ml | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/ocaml-lsp-server/src/ocaml_lsp_server.ml b/ocaml-lsp-server/src/ocaml_lsp_server.ml index 5af0dae98..53195f692 100644 --- a/ocaml-lsp-server/src/ocaml_lsp_server.ml +++ b/ocaml-lsp-server/src/ocaml_lsp_server.ml @@ -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