From 0ac7c7839f4d8a3fe173177921e8d058c405da6d Mon Sep 17 00:00:00 2001 From: Federico Igne Date: Thu, 11 Jan 2024 23:14:53 +0100 Subject: fix: off-by-one error in cursor update procedure --- lib/editor.ml | 4 ++-- 1 file 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 match Option.map ~f:Buffer.cursor e.buffer with | None -> { e with cursor = (1, 1); offset = (0, 0) } | Some (cx, cy) -> - let dx' = Int.clamp_exn ~min:(cx - rs) ~max:cx dx - and dy' = Int.clamp_exn ~min:(cy - cs) ~max:cy dy in + let dx' = Int.clamp_exn ~min:(cx - rs + 1) ~max:cx dx + and dy' = Int.clamp_exn ~min:(cy - cs + 1) ~max:cy dy in { e with cursor = (cx - dx' + 1, cy - dy' + 1); offset = (dx', dy') } in modify ~f:aux -- cgit v1.2.3