diff options
author | Federico Igne <undyamon@disroot.org> | 2024-01-11 23:14:53 +0100 |
---|---|---|
committer | Federico Igne <undyamon@disroot.org> | 2024-01-11 23:14:53 +0100 |
commit | 0ac7c7839f4d8a3fe173177921e8d058c405da6d (patch) | |
tree | f30ecb32b3ebdefcc75b70a18fff932959c69bde | |
parent | 235f74aad290186785bf4c66aec805bb4577f7eb (diff) | |
download | sandy-0ac7c7839f4d8a3fe173177921e8d058c405da6d.tar.gz sandy-0ac7c7839f4d8a3fe173177921e8d058c405da6d.zip |
fix: off-by-one error in cursor update procedure
-rw-r--r-- | lib/editor.ml | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/lib/editor.ml b/lib/editor.ml index a516b25..959b3af 100644 --- a/lib/editor.ml +++ b/lib/editor.ml | |||
@@ -72,8 +72,8 @@ module Action = struct | |||
72 | match Option.map ~f:Buffer.cursor e.buffer with | 72 | match Option.map ~f:Buffer.cursor e.buffer with |
73 | | None -> { e with cursor = (1, 1); offset = (0, 0) } | 73 | | None -> { e with cursor = (1, 1); offset = (0, 0) } |
74 | | Some (cx, cy) -> | 74 | | Some (cx, cy) -> |
75 | let dx' = Int.clamp_exn ~min:(cx - rs) ~max:cx dx | 75 | let dx' = Int.clamp_exn ~min:(cx - rs + 1) ~max:cx dx |
76 | and dy' = Int.clamp_exn ~min:(cy - cs) ~max:cy dy in | 76 | and dy' = Int.clamp_exn ~min:(cy - cs + 1) ~max:cy dy in |
77 | { e with cursor = (cx - dx' + 1, cy - dy' + 1); offset = (dx', dy') } | 77 | { e with cursor = (cx - dx' + 1, cy - dy' + 1); offset = (dx', dy') } |
78 | in | 78 | in |
79 | modify ~f:aux | 79 | modify ~f:aux |