From 6744e57c68589249cb9ef3a725b0391b42177d46 Mon Sep 17 00:00:00 2001 From: Qwerasd Date: Wed, 9 Jul 2025 22:27:50 -0600 Subject: [PATCH] fix(terminal/PageList): update viewport in row count resize Before, if the row count increase past the active area then we added new rows to make sure that we had enough for the active area, but we didn't make sure that the viewport pin wasn't below the active area pin, which meant that later on if someone tried to get the bottom right pin for the viewport it would overshoot and we'd use null. This resulted in either a memory corruption bug in ReleaseFast if you scaled down the font while scrolled up slightly, or in Debug mode it was just a crash. --- src/terminal/PageList.zig | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/terminal/PageList.zig b/src/terminal/PageList.zig index 9838bfb53..d13cd7fef 100644 --- a/src/terminal/PageList.zig +++ b/src/terminal/PageList.zig @@ -1401,6 +1401,15 @@ fn resizeWithoutReflow(self: *PageList, opts: Resize) !void { assert(count < rows); for (count..rows) |_| _ = try self.grow(); } + + // Make sure that the viewport pin isn't below the active + // area, since that will lead to all sorts of problems. + switch (self.viewport) { + .pin => if (self.pinIsActive(self.viewport_pin.*)) { + self.viewport = .{ .active = {} }; + }, + .active, .top => {}, + } }, }