From 050e6e4daa897c818fc7d837807cac41b02106a8 Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Wed, 27 Mar 2024 10:38:31 -0700 Subject: [PATCH] terminal: when growing rows, need to set rows before grow() grow() will not prune pages that are needed for the active but that requires an accurate self.rows. We were setting this too late. --- src/terminal/PageList.zig | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/terminal/PageList.zig b/src/terminal/PageList.zig index bacb553b0..b7ab72049 100644 --- a/src/terminal/PageList.zig +++ b/src/terminal/PageList.zig @@ -1347,11 +1347,17 @@ fn resizeWithoutReflow(self: *PageList, opts: Resize) !void { // Cursor is not at the bottom, so we just grow our // rows and we're done. Cursor does NOT change for this // since we're not pulling down scrollback. - for (0..rows - self.rows) |_| _ = try self.grow(); + const delta = rows - self.rows; self.rows = rows; + for (0..delta) |_| _ = try self.grow(); break :gt; } + // This must be set BEFORE any calls to grow() so that + // grow() doesn't prune pages that we need for the active + // area. + self.rows = rows; + // Cursor is at the bottom or we don't care about cursors. // In this case, if we have enough rows in our pages, we // just update our rows and we're done. This effectively @@ -1368,8 +1374,6 @@ fn resizeWithoutReflow(self: *PageList, opts: Resize) !void { assert(count < rows); for (count..rows) |_| _ = try self.grow(); } - - self.rows = rows; }, } @@ -2091,7 +2095,7 @@ pub fn eraseRowBounded( // and update our pins. if (page.data.size.rows - pn.y > limit) { page.data.clearCells(&rows[pn.y], 0, page.data.size.cols); - fastmem.rotateOnce(Row, rows[pn.y..][0..limit + 1]); + fastmem.rotateOnce(Row, rows[pn.y..][0 .. limit + 1]); // Update pins in the shifted region. var pin_it = self.tracked_pins.keyIterator(); @@ -2135,7 +2139,7 @@ pub fn eraseRowBounded( const shifted_limit = limit - shifted; if (page.data.size.rows > shifted_limit) { page.data.clearCells(&rows[0], 0, page.data.size.cols); - fastmem.rotateOnce(Row, rows[0..shifted_limit + 1]); + fastmem.rotateOnce(Row, rows[0 .. shifted_limit + 1]); // Update pins in the shifted region. var pin_it = self.tracked_pins.keyIterator();