From 6f451f22bb6fea80d9fdb805e51b5150457fdf5c Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Wed, 14 Dec 2022 21:39:45 -0800 Subject: [PATCH] terminal: only clear wide spacer head if wide char is not on first line --- src/terminal/Terminal.zig | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/terminal/Terminal.zig b/src/terminal/Terminal.zig index 8cca30fa5..1ab9bb80c 100644 --- a/src/terminal/Terminal.zig +++ b/src/terminal/Terminal.zig @@ -672,7 +672,7 @@ fn printCell(self: *Terminal, unmapped_c: u21) *Screen.Cell { const spacer_cell = row.getCellPtr(x); spacer_cell.attrs.wide_spacer_tail = false; - if (self.screen.cursor.x <= 1) { + if (self.screen.cursor.y > 0 and self.screen.cursor.x <= 1) { self.clearWideSpacerHead(); } } else if (cell.attrs.wide_spacer_tail) { @@ -1415,6 +1415,18 @@ test "Terminal: zero-width character at start" { try testing.expectEqual(@as(usize, 0), t.screen.cursor.x); } +test "Terminal: print over wide char at 0,0" { + var t = try init(testing.allocator, 80, 80); + defer t.deinit(testing.allocator); + + try t.print(0x1F600); // Smiley face + t.setCursorPos(0, 0); + try t.print('A'); // Smiley face + + try testing.expectEqual(@as(usize, 0), t.screen.cursor.y); + try testing.expectEqual(@as(usize, 1), t.screen.cursor.x); +} + test "Terminal: soft wrap" { var t = try init(testing.allocator, 3, 80); defer t.deinit(testing.allocator);