Skip to content

Commit

Permalink
Remove List.find_mapi (not available before 5.1)
Browse files Browse the repository at this point in the history
  • Loading branch information
xvw committed Jul 1, 2024
1 parent 87a7d4d commit 08f67e5
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions ocaml-lsp-server/src/custom_requests/req_type_enclosing.ml
Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,8 @@ let make_enclosing_command position index =
Query_protocol.Type_enclosing (None, position, Some index)

let get_first_enclosing_index range_end enclosings =
List.find_mapi
~f:(fun i (loc, _, _) ->
let rec aux i = function
| (loc, _, _) :: xs -> (
let range = Range.of_loc loc in
match
( Position.compare range_end range.start
Expand All @@ -118,8 +118,10 @@ let get_first_enclosing_index range_end enclosings =
| Ordering.Lt, Ordering.Lt
| Ordering.Lt, Ordering.Eq
| Ordering.Lt, Ordering.Gt
| Ordering.Eq, Ordering.Gt -> None)
enclosings
| Ordering.Eq, Ordering.Gt -> aux (succ i) xs)
| _ -> None
in
aux 0 enclosings

let dispatch_command pipeline command first_index index =
let rec aux i acc = function
Expand Down

0 comments on commit 08f67e5

Please sign in to comment.