diff --git a/src/terminal/Screen.zig b/src/terminal/Screen.zig index a0a48d40c..0d2d74eb6 100644 --- a/src/terminal/Screen.zig +++ b/src/terminal/Screen.zig @@ -809,6 +809,10 @@ pub fn clearRows( var it = self.pages.pageIterator(.right_down, tl, bl); while (it.next()) |chunk| { + // Mark everything in this chunk as dirty + var dirty = chunk.page.data.dirtyBitSet(); + dirty.setRangeValue(.{ .start = chunk.start, .end = chunk.end }, true); + for (chunk.rows()) |*row| { const cells_offset = row.cells; const cells_multi: [*]Cell = row.cells.ptr(chunk.page.data.memory); @@ -2508,6 +2512,7 @@ test "Screen clearRows active one line" { try s.testWriteString("hello, world"); s.clearRows(.{ .active = .{} }, null, false); + try testing.expect(s.pages.isDirty(.{ .active = .{ .x = 0, .y = 0 } })); const str = try s.dumpStringAlloc(alloc, .{ .screen = .{} }); defer alloc.free(str); try testing.expectEqualStrings("", str); @@ -2522,6 +2527,8 @@ test "Screen clearRows active multi line" { try s.testWriteString("hello\nworld"); s.clearRows(.{ .active = .{} }, null, false); + try testing.expect(s.pages.isDirty(.{ .active = .{ .x = 0, .y = 0 } })); + try testing.expect(s.pages.isDirty(.{ .active = .{ .x = 0, .y = 1 } })); const str = try s.dumpStringAlloc(alloc, .{ .screen = .{} }); defer alloc.free(str); try testing.expectEqualStrings("", str); diff --git a/src/terminal/Terminal.zig b/src/terminal/Terminal.zig index c44b56adb..b242e959c 100644 --- a/src/terminal/Terminal.zig +++ b/src/terminal/Terminal.zig @@ -8662,8 +8662,14 @@ test "Terminal: eraseDisplay simple erase below" { try t.linefeed(); for ("GHI") |c| try t.print(c); t.setCursorPos(2, 2); + + t.clearDirty(); t.eraseDisplay(.below, false); + try testing.expect(!t.isDirty(.{ .active = .{ .x = 0, .y = 0 } })); + try testing.expect(t.isDirty(.{ .active = .{ .x = 0, .y = 1 } })); + try testing.expect(t.isDirty(.{ .active = .{ .x = 0, .y = 2 } })); + { const str = try t.plainString(testing.allocator); defer testing.allocator.free(str); @@ -8840,7 +8846,12 @@ test "Terminal: eraseDisplay simple erase above" { try t.linefeed(); for ("GHI") |c| try t.print(c); t.setCursorPos(2, 2); + + t.clearDirty(); t.eraseDisplay(.above, false); + try testing.expect(t.isDirty(.{ .active = .{ .x = 0, .y = 0 } })); + try testing.expect(t.isDirty(.{ .active = .{ .x = 0, .y = 1 } })); + try testing.expect(!t.isDirty(.{ .active = .{ .x = 0, .y = 2 } })); { const str = try t.plainString(testing.allocator); @@ -9018,7 +9029,10 @@ test "Terminal: eraseDisplay protected complete" { t.setProtectedMode(.dec); try t.print('X'); t.setCursorPos(t.screen.cursor.y + 1, 4); + + t.clearDirty(); t.eraseDisplay(.complete, true); + for (0..t.rows) |y| try testing.expect(t.isDirty(.{ .active = .{ .x = 0, .y = y } })); { const str = try t.plainString(testing.allocator);