From 1d1d828097b07f44a982dd37d7f767afc855ebd8 Mon Sep 17 00:00:00 2001 From: CJ van den Berg Date: Mon, 3 Nov 2025 16:25:22 +0100 Subject: [PATCH] fix: move cursor to the beginning of an egc in Cursor.clamp_to_buffer closes #317 --- src/buffer/Cursor.zig | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/buffer/Cursor.zig b/src/buffer/Cursor.zig index 31099cf..5a871cf 100644 --- a/src/buffer/Cursor.zig +++ b/src/buffer/Cursor.zig @@ -33,6 +33,8 @@ pub fn clamp_to_buffer(self: *Self, root: Buffer.Root, metrics: Metrics) void { self.col = root.line_width(self.row, metrics) catch 0; } else { self.col = @min(self.col, root.line_width(self.row, metrics) catch 0); + _, _, const offset = root.egc_at(self.row, self.col, metrics) catch return; + self.col -= @min(self.col, offset); } }