From 5f87e09d61e6eb81ed01a876a5a8e51783397ae4 Mon Sep 17 00:00:00 2001 From: Tim Culverhouse Date: Sun, 24 Sep 2023 16:04:47 -0500 Subject: [PATCH] terminal: make deleteChars insert blank cells When DCH (deleteChars) deletes cells from a line, cells are inserted from the right. The new cells should not have the current pen style, and should instead be an empty cell. Add check for this in the existing test. Fixes: alacritty/deccolm_reset --- src/terminal/Terminal.zig | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/terminal/Terminal.zig b/src/terminal/Terminal.zig index 58b93fb0c..d4311415a 100644 --- a/src/terminal/Terminal.zig +++ b/src/terminal/Terminal.zig @@ -1282,7 +1282,7 @@ pub fn deleteChars(self: *Terminal, count: usize) !void { for (self.screen.cursor.x..self.cols) |x| { const copy_x = x + count; if (copy_x >= self.cols) { - line.getCellPtr(x).* = self.screen.cursor.pen; + line.getCellPtr(x).* = .{}; continue; } @@ -2810,11 +2810,17 @@ test "Terminal: deleteChars" { for ("ABCDE") |c| try t.print(c); t.setCursorPos(1, 2); + // the cells that shifted in should not have this attribute set + t.screen.cursor.pen = .{ .attrs = .{ .bold = true } }; + try t.deleteChars(2); { var str = try t.plainString(testing.allocator); defer testing.allocator.free(str); try testing.expectEqualStrings("ADE", str); + + const cell = t.screen.getCell(.active, 0, 4); + try testing.expect(!cell.attrs.bold); } }