Severity: MEDIUM
Status: Fixed
Files: src/grid.zig, src/screen.zig
split-window -v or prefix + "), the original pane’s height is halved (e.g. from 24 rows to 11 rows).In Grid.resize:
pub fn resize(self: *Grid, new_height: u32) Error!void {
if (new_height == 0) return;
try self.normalize();
while (self.lines.items.len < new_height) {
var line = GridLine{};
try line.cells.resize(self.allocator, self.width);
@memset(line.cells.items, Cell.empty());
try self.lines.append(self.allocator, line);
}
while (self.lines.items.len > new_height) {
var line = self.lines.pop().?;
self.notifyEvict(line.cells.items);
line.deinit(self.allocator);
}
self.height = new_height;
}
lines.pop() discards newest/bottom rows:
self.normalize() rotates the ring buffer so that row 0 is at index 0 and row height - 1 is at the end of self.lines.items. When new_height < self.lines.items.len, while (self.lines.items.len > new_height) self.lines.pop() removes rows from the end (the bottom of the screen).Grid.history), leaving the bottom rows (where the prompt and cursor reside) in view.Screen.resize, self.cursor.y is clamped to new_height - 1. Because the bottom lines were deleted rather than shifted up, the cursor is placed on top of whatever older text was at row new_height - 1, clobbering display state.Grid.resize (new_height < self.lines.items.len):
const excess = self.lines.items.len - new_height;.excess rows off the top of the visible screen into self.history (respecting history_limit and ring buffer indexing, identical to scrollUp).new_height rows to the front of self.lines.items and truncate self.lines.items.len = new_height.src/grid.zig verifying that shrinking height pushes top lines into scrollback history and preserves the bottom lines on the visible screen.