From 9df9c999a7b9f1d674d417ff52c2139b9b4cf34b Mon Sep 17 00:00:00 2001 From: Qwerasd Date: Mon, 25 Mar 2024 14:54:49 -0600 Subject: [PATCH] fix(terminal): clear erased rows Clearing these rows is necessary to avoid memory corruption, but the calls to `clearCells` in the first loop were redundant, since the rows in question are included in the second loop as well. --- src/terminal/PageList.zig | 23 ++++++++++------------- 1 file changed, 10 insertions(+), 13 deletions(-) diff --git a/src/terminal/PageList.zig b/src/terminal/PageList.zig index dea1a739e..9010407f7 100644 --- a/src/terminal/PageList.zig +++ b/src/terminal/PageList.zig @@ -2093,21 +2093,18 @@ pub fn eraseRows( const old_dst = dst.*; dst.* = src.*; src.* = old_dst; - - // // Clear the old data in case we reuse these cells. - // chunk.page.data.clearCells(src, 0, chunk.page.data.size.cols); } - // // Clear our remaining cells that we didn't shift or swapped - // // in case we grow back into them. - // for (scroll_amount..chunk.page.data.size.rows) |i| { - // const row: *Row = &rows[i]; - // chunk.page.data.clearCells( - // row, - // 0, - // chunk.page.data.size.cols, - // ); - // } + // Clear our remaining cells that we didn't shift or swapped + // in case we grow back into them. + for (scroll_amount..chunk.page.data.size.rows) |i| { + const row: *Row = &rows[i]; + chunk.page.data.clearCells( + row, + 0, + chunk.page.data.size.cols, + ); + } // Update any tracked pins to shift their y. If it was in the erased // row then we move it to the top of this page.