diff --git a/src/terminal/PageList.zig b/src/terminal/PageList.zig index 02f9d0272..e1da55ad4 100644 --- a/src/terminal/PageList.zig +++ b/src/terminal/PageList.zig @@ -4861,7 +4861,9 @@ test "PageList clone full dirty" { // Should still be dirty try testing.expect(s2.isDirty(.{ .active = .{ .x = 0, .y = 0 } })); + try testing.expect(!s2.isDirty(.{ .active = .{ .x = 0, .y = 1 } })); try testing.expect(s2.isDirty(.{ .active = .{ .x = 0, .y = 12 } })); + try testing.expect(!s2.isDirty(.{ .active = .{ .x = 0, .y = 14 } })); try testing.expect(s2.isDirty(.{ .active = .{ .x = 0, .y = 23 } })); } diff --git a/src/terminal/page.zig b/src/terminal/page.zig index 4d3c0b1fd..7137431cf 100644 --- a/src/terminal/page.zig +++ b/src/terminal/page.zig @@ -500,16 +500,12 @@ pub const Page = struct { const other_rows = other.rows.ptr(other.memory)[y_start..y_end]; const rows = self.rows.ptr(self.memory)[0 .. y_end - y_start]; - for (rows, other_rows) |*dst_row, *src_row| { - try self.cloneRowFrom(other, dst_row, src_row); - } - - // Set our dirty range for all the rows we copied + const other_dirty_set = other.dirtyBitSet(); var dirty_set = self.dirtyBitSet(); - dirty_set.setRangeValue(.{ - .start = 0, - .end = y_end - y_start, - }, true); + for (rows, 0.., other_rows, y_start..) |*dst_row, dst_y, *src_row, src_y| { + try self.cloneRowFrom(other, dst_row, src_row); + if (other_dirty_set.isSet(src_y)) dirty_set.set(dst_y); + } // We should remain consistent self.assertIntegrity();