fix(terminal/PageList): ensure enough pages before first page reuse

Running alacritty/vtebench on some machines causes Ghostty to fail on
`assert(first != last)` when trying to grow scrollback. We now make sure
we have enough pages before trying to reuse pages.
This commit is contained in:
Khang Nguyen Duy
2024-09-21 21:46:25 +07:00
parent c6bbdfb7bf
commit d5ab772b66

View File

@ -1694,7 +1694,7 @@ pub fn grow(self: *PageList) !?*List.Node {
// If allocation would exceed our max size, we prune the first page.
// We don't need to reallocate because we can simply reuse that first
// page.
if (self.page_size + PagePool.item_size > self.maxSize()) prune: {
if (self.pages.len > 1 and self.page_size + PagePool.item_size > self.maxSize()) prune: {
// If we need to add more memory to ensure our active area is
// satisfied then we do not prune.
if (self.growRequiredForActive()) break :prune;