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.
This commit is contained in:
CJ van den Berg 2025-09-13 15:45:17 +02:00
parent 79487baa6e
commit 3d90b199ad
Signed by: neurocyte
GPG key ID: 8EB1E1BB660E3FB9

View file

@ -538,7 +538,7 @@ const Node = union(enum) {
const ctx = @as(*@This(), @ptrCast(@alignCast(ctx_))); const ctx = @as(*@This(), @ptrCast(@alignCast(ctx_)));
ctx.at = egc; ctx.at = egc;
ctx.wcwidth = wcwidth; 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; return Walker.stop;
ctx.col -= wcwidth; ctx.col -= wcwidth;
return Walker.keep_walking; return Walker.keep_walking;