From 66d97ab5f3ff3e96dfa762ef38e4024f63a5e2e4 Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Tue, 24 Oct 2023 12:20:37 -0700 Subject: [PATCH] terminal: do not attach grapheme to empty cell --- src/terminal/Terminal.zig | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/terminal/Terminal.zig b/src/terminal/Terminal.zig index efa6c6db7..beed80ec6 100644 --- a/src/terminal/Terminal.zig +++ b/src/terminal/Terminal.zig @@ -648,7 +648,7 @@ pub fn print(self: *Terminal, c: u21) !void { if (c > 255 and self.modes.get(.grapheme_cluster) and self.screen.cursor.x > 0) - { + grapheme: { const row = self.screen.getRow(.{ .active = self.screen.cursor.y }); // We need the previous cell to determine if we're at a grapheme @@ -673,6 +673,10 @@ pub fn print(self: *Terminal, c: u21) !void { }; }; + // If our cell has no content, then this is a new cell and + // necessarily a grapheme break. + if (prev.cell.char == 0) break :grapheme; + const grapheme_break = brk: { var state: i32 = 0; var cp1 = @as(u21, @intCast(prev.cell.char));