From 1704923062e6cc0f341e34ec32a4ed60baad7bc9 Mon Sep 17 00:00:00 2001 From: Jack Feser Date: Wed, 8 Sep 2021 19:50:14 -0400 Subject: [PATCH] Filter -> find --- .../src/code_actions/action_mark_remove_unused.ml | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/ocaml-lsp-server/src/code_actions/action_mark_remove_unused.ml b/ocaml-lsp-server/src/code_actions/action_mark_remove_unused.ml index 66597af5f..b13c2e996 100644 --- a/ocaml-lsp-server/src/code_actions/action_mark_remove_unused.ml +++ b/ocaml-lsp-server/src/code_actions/action_mark_remove_unused.ml @@ -76,11 +76,13 @@ let code_action_remove_value doc pos (diagnostic : Diagnostic.t) = let code_action doc (params : CodeActionParams.t) = let pos = params.range.start in let diag = - List.filter params.context.diagnostics ~f:(fun (d : Diagnostic.t) -> - match Position.compare_inclusion pos d.range with - | `Outside _ -> false - | `Inside -> true) - |> List.find ~f:Diagnostic_util.is_unused_var_warning + List.find params.context.diagnostics ~f:(fun (d : Diagnostic.t) -> + let in_range = + match Position.compare_inclusion pos d.range with + | `Outside _ -> false + | `Inside -> true + in + in_range && Diagnostic_util.is_unused_var_warning d) in match diag with | None -> Fiber.return []