test(terminal/PageList): resize keeps viewport <= active

This tests for the bug fixed in the last commit.
This commit is contained in:
Qwerasd
2025-07-09 22:47:01 -06:00
parent 6744e57c68
commit ea4a056d34

View File

@ -5984,6 +5984,36 @@ test "PageList resize (no reflow) more rows extends blank lines" {
}
}
test "PageList resize (no reflow) more rows contains viewport" {
const testing = std.testing;
const alloc = testing.allocator;
// When the rows are increased we need to make sure that the viewport
// doesn't end up below the active area if it's currently in pin mode.
var s = try init(alloc, 5, 5, 1);
defer s.deinit();
try testing.expect(s.pages.first == s.pages.last);
// Make it so we have scrollback
_ = try s.grow();
try testing.expectEqual(@as(usize, 5), s.rows);
try testing.expectEqual(@as(usize, 6), s.totalRows());
// Set viewport above active by scrolling up one.
s.scroll(.{ .delta_row = -1 });
// The viewport should be a pin now.
try testing.expectEqual(Viewport.pin, s.viewport);
// Resize
try s.resize(.{ .rows = 7, .reflow = false });
try testing.expectEqual(@as(usize, 7), s.rows);
try testing.expectEqual(@as(usize, 7), s.totalRows());
// The viewport should now be active, not a pin.
try testing.expectEqual(Viewport.active, s.viewport);
}
test "PageList resize (no reflow) less cols" {
const testing = std.testing;
const alloc = testing.allocator;