terminal: do not attach grapheme to empty cell

This commit is contained in:
Mitchell Hashimoto
2023-10-24 12:20:37 -07:00
parent 1457bcec90
commit 66d97ab5f3

View File

@ -648,7 +648,7 @@ pub fn print(self: *Terminal, c: u21) !void {
if (c > 255 and if (c > 255 and
self.modes.get(.grapheme_cluster) and self.modes.get(.grapheme_cluster) and
self.screen.cursor.x > 0) self.screen.cursor.x > 0)
{ grapheme: {
const row = self.screen.getRow(.{ .active = self.screen.cursor.y }); const row = self.screen.getRow(.{ .active = self.screen.cursor.y });
// We need the previous cell to determine if we're at a grapheme // 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: { const grapheme_break = brk: {
var state: i32 = 0; var state: i32 = 0;
var cp1 = @as(u21, @intCast(prev.cell.char)); var cp1 = @as(u21, @intCast(prev.cell.char));