From a40899fa3ceb175777639a2b7f192e5e07bb84e4 Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Tue, 19 Mar 2024 12:54:38 -0700 Subject: [PATCH] terminal: only reload style if we're on a new page on scroll --- src/terminal/Screen.zig | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/terminal/Screen.zig b/src/terminal/Screen.zig index 4184b40fc..0d4999f56 100644 --- a/src/terminal/Screen.zig +++ b/src/terminal/Screen.zig @@ -527,12 +527,14 @@ pub fn cursorDownScroll(self: *Screen) !void { } if (self.cursor.style_id != style.default_id) { - // We need to ensure our new page has our style. - self.manualStyleUpdate() catch |err| { + // We need to ensure our new page has our style. This is a somewhat + // expensive operation so we only do it if our page pin y is on zero, + // which signals we're at the top of a page. + if (self.cursor.page_pin.y == 0) { // This should never happen because if we're in a new // page then we should have space for one style. - log.warn("error updating style on scroll err={}", .{err}); - }; + try self.manualStyleUpdate(); + } // The newly created line needs to be styled according to // the bg color if it is set.