terminal: pagelist handle scenario where reflow erases all pages

This commit is contained in:
Mitchell Hashimoto
2024-03-20 20:31:49 -07:00
parent cc75cc9980
commit dfa5b2e6fc

View File

@ -825,8 +825,18 @@ fn reflowPage(
while (src_cursor.page_row.wrap_continuation) { while (src_cursor.page_row.wrap_continuation) {
// If this entire page was continuations then we can remove it. // If this entire page was continuations then we can remove it.
if (src_cursor.y == src_cursor.page.size.rows - 1) { if (src_cursor.y == src_cursor.page.size.rows - 1) {
self.pages.remove(initial_node); // If this is the last page, then we need to insert an empty
self.destroyPage(initial_node); // page so that erasePage works. This is a rare scenario that
// can happen in no-scrollback pages where EVERY line is
// a continuation.
if (initial_node.prev == null and initial_node.next == null) {
const cap = try std_capacity.adjust(.{ .cols = cols });
const node = try self.createPage(cap);
self.pages.insertAfter(initial_node, node);
}
self.erasePage(initial_node);
assert(self.page_size <= self.maxSize());
return; return;
} }