Severity: MEDIUM Status: Fixed
visibleLen counts one column per codepoint, treating wide characters (CJK, emoji, etc.) as a single column:
// src/status.zig:108-123
pub fn visibleLen(s: []const u8) usize {
var cols: usize = 0;
var i: usize = 0;
while (i < s.len) {
if (s[i] == 0x1b) { i = skipEscape(s, i); continue; }
const cp_len = std.unicode.utf8ByteSequenceLength(s[i]) catch 1;
cols += 1; // always +1, ignores wide chars
i += cp_len;
}
return cols;
}
buildLine derives the per-window mouse hit ranges from this metric:
// src/status.zig:331-341
const cols = visibleLen(piece);
const start_col = centre_cursor;
centre_cursor += cols;
try r.append(allocator, .{ .pos = ..., .start_col = ..., .end_col = centre_cursor });
visibleLen under-counts a wide-char window name by 1 column per wide char. The internally-computed WindowRange (used by handleMouseFocus) then diverges from the terminal’s actual column coordinates, which render wide chars at 2 cells.Use char_width.zig cell-width lookup inside visibleLen (count 2 for wide chars), or compute the ranges from the same width function the renderer uses, so the internal ranges match terminal cell coordinates.