From 257aafb7b44db09252e1ae5a8d63a9e8920f788d Mon Sep 17 00:00:00 2001 From: Daniel Wennberg Date: Mon, 12 Jan 2026 09:32:33 -0800 Subject: [PATCH] Consolidate dirty marking in insertLines/deleteLines --- src/terminal/Terminal.zig | 26 ++++++-------------------- 1 file changed, 6 insertions(+), 20 deletions(-) diff --git a/src/terminal/Terminal.zig b/src/terminal/Terminal.zig index 7b384f34e..d717a9724 100644 --- a/src/terminal/Terminal.zig +++ b/src/terminal/Terminal.zig @@ -1602,9 +1602,6 @@ pub fn insertLines(self: *Terminal, count: usize) void { const cur_rac = cur_p.rowAndCell(); const cur_row: *Row = cur_rac.row; - // Mark the row as dirty - cur_p.markDirty(); - // If this is one of the lines we need to shift, do so if (y > adjusted_count) { const off_p = cur_p.up(adjusted_count).?; @@ -1690,10 +1687,6 @@ pub fn insertLines(self: *Terminal, count: usize) void { // Continue the loop to try handling this row again. continue; }; - - // The clone operation may overwrite the dirty flag, so make - // sure the row is still marked dirty. - dst_row.dirty = true; } else { if (!left_right) { // Swap the src/dst cells. This ensures that our dst gets the @@ -1703,9 +1696,6 @@ pub fn insertLines(self: *Terminal, count: usize) void { dst_row.* = src_row.*; src_row.* = dst; - // Make sure the row is marked as dirty though. - dst_row.dirty = true; - // Ensure what we did didn't corrupt the page cur_p.node.data.assertIntegrity(); } else { @@ -1732,6 +1722,9 @@ pub fn insertLines(self: *Terminal, count: usize) void { ); } + // Mark the row as dirty + cur_p.markDirty(); + // We have successfully processed a line. y -= 1; // Move our pin up to the next row. @@ -1809,9 +1802,6 @@ pub fn deleteLines(self: *Terminal, count: usize) void { const cur_rac = cur_p.rowAndCell(); const cur_row: *Row = cur_rac.row; - // Mark the row as dirty - cur_p.markDirty(); - // If this is one of the lines we need to shift, do so if (y < rem - adjusted_count) { const off_p = cur_p.down(adjusted_count).?; @@ -1892,10 +1882,6 @@ pub fn deleteLines(self: *Terminal, count: usize) void { // Continue the loop to try handling this row again. continue; }; - - // The clone operation may overwrite the dirty flag, so make - // sure the row is still marked dirty. - dst_row.dirty = true; } else { if (!left_right) { // Swap the src/dst cells. This ensures that our dst gets the @@ -1905,9 +1891,6 @@ pub fn deleteLines(self: *Terminal, count: usize) void { dst_row.* = src_row.*; src_row.* = dst; - // Make sure the row is marked as dirty though. - dst_row.dirty = true; - // Ensure what we did didn't corrupt the page cur_p.node.data.assertIntegrity(); } else { @@ -1934,6 +1917,9 @@ pub fn deleteLines(self: *Terminal, count: usize) void { ); } + // Mark the row as dirty + cur_p.markDirty(); + // We have successfully processed a line. y += 1; // Move our pin down to the next row.