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.
This commit is contained in:
Qwerasd
2025-07-09 22:27:50 -06:00
parent ffc6fe8686
commit 6744e57c68

View File

@ -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 => {},
}
},
}