From 3d90b199ad90e1b7f272411eb04a4f1293ed8c73 Mon Sep 17 00:00:00 2001 From: CJ van den Berg Date: Sat, 13 Sep 2025 15:45:17 +0200 Subject: [PATCH] fix: do not return zero width codepoints from egc_at Skip them and return the next non-zero width codepoint. This makes more sense and prevents endless loops in code that scans by egc width using egc_at, like Cursor.move_right_until for example. --- src/buffer/Buffer.zig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/buffer/Buffer.zig b/src/buffer/Buffer.zig index ddcf889..7d6c5d9 100644 --- a/src/buffer/Buffer.zig +++ b/src/buffer/Buffer.zig @@ -538,7 +538,7 @@ const Node = union(enum) { const ctx = @as(*@This(), @ptrCast(@alignCast(ctx_))); ctx.at = egc; ctx.wcwidth = wcwidth; - if (ctx.col == 0 or egc[0] == '\n' or ctx.col < wcwidth) + if (wcwidth > 0 and (ctx.col == 0 or egc[0] == '\n' or ctx.col < wcwidth)) return Walker.stop; ctx.col -= wcwidth; return Walker.keep_walking;