From 8b7b61205126412403034021990cae3dde1703a2 Mon Sep 17 00:00:00 2001 From: Emilien Lemaire Date: Fri, 17 May 2024 10:57:33 -0600 Subject: [PATCH] fix(lsp): goto_line_backward abs_pos fix book-keeping of [abs_pos] in [String_zipper.goto_line_backward] --- lsp/src/string_zipper.ml | 2 +- lsp/test/string_zipper_tests.ml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lsp/src/string_zipper.ml b/lsp/src/string_zipper.ml index b563c9617..9e5cb0eef 100644 --- a/lsp/src/string_zipper.ml +++ b/lsp/src/string_zipper.ml @@ -292,7 +292,7 @@ let drop_until from until = | [] -> empty | current :: left -> let rel_pos = Substring.length current in - let abs_pos = from.rel_pos + rel_pos in + let abs_pos = from.abs_pos + rel_pos in { from with right; left; current; rel_pos; abs_pos }) let add_buffer_between b start stop = diff --git a/lsp/test/string_zipper_tests.ml b/lsp/test/string_zipper_tests.ml index ce00706d1..7b948704d 100644 --- a/lsp/test/string_zipper_tests.ml +++ b/lsp/test/string_zipper_tests.ml @@ -173,4 +173,4 @@ let%expect_test "drop_until bug" = "foo\nbar\n|" |}]; printfn "abs_pos: %d" (String_zipper.Private.reflect t).abs_pos; [%expect {| - abs_pos: 16 |}] + abs_pos: 8 |}]