From 9c2a5bccc1e0570e4e2706d5f76514f1e499d26c Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Sat, 9 Mar 2024 20:48:46 -0800 Subject: [PATCH] terminal: page size should be accounted every creation --- src/terminal/PageList.zig | 9 +++++++-- src/terminal/kitty/graphics_storage.zig | 2 +- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/src/terminal/PageList.zig b/src/terminal/PageList.zig index 96368109f..808ec8440 100644 --- a/src/terminal/PageList.zig +++ b/src/terminal/PageList.zig @@ -1387,8 +1387,8 @@ pub fn grow(self: *PageList) !?*List.Node { self.pages.append(next_page); next_page.data.size.rows = 1; - // Accounting - self.page_size += PagePool.item_size; + // We should never be more than our max size here because we've + // verified the case above. assert(self.page_size <= self.max_size); return next_page; @@ -1412,6 +1412,11 @@ fn createPage(self: *PageList, cap: Capacity) !*List.Node { }; page.data.size.rows = 0; + // Accumulate page size now. We don't assert or check max size because + // we may exceed it here temporarily as we are allocating pages before + // destroy. + self.page_size += PagePool.item_size; + return page; } diff --git a/src/terminal/kitty/graphics_storage.zig b/src/terminal/kitty/graphics_storage.zig index d84a0a122..534d1b33f 100644 --- a/src/terminal/kitty/graphics_storage.zig +++ b/src/terminal/kitty/graphics_storage.zig @@ -635,7 +635,7 @@ pub const ImageStorage = struct { // Our pin for the placement fn trackPin( t: *terminal.Terminal, - pt: point.Point.Coordinate, + pt: point.Coordinate, ) !*PageList.Pin { return try t.screen.pages.trackPin(t.screen.pages.pin(.{ .active = pt,