Consolidate dirty marking in insertLines/deleteLines

This commit is contained in:
Daniel Wennberg
2026-01-12 09:32:33 -08:00
parent 095c82910b
commit 257aafb7b4

View File

@@ -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.