From 2c924be9b1431ed671cf39d7b60db0302c9c0fb3 Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Sun, 21 Jan 2024 20:55:41 -0800 Subject: [PATCH] core: only dump scrollback contents if there is scrollback Fixes #1353 --- src/Surface.zig | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/src/Surface.zig b/src/Surface.zig index 4b6d151dd..c0670c8b8 100644 --- a/src/Surface.zig +++ b/src/Surface.zig @@ -2933,11 +2933,16 @@ pub fn performBindingAction(self: *Surface, action: input.Binding.Action) !bool &self.io.terminal.screen, ); - try self.io.terminal.screen.dumpString(file.writer(), .{ - .start = .{ .history = 0 }, - .end = .{ .history = history_max -| 1 }, - .unwrap = true, - }); + // We only dump history if we have history. We still keep + // the file and write the empty file to the pty so that this + // command always works on the primary screen. + if (history_max > 0) { + try self.io.terminal.screen.dumpString(file.writer(), .{ + .start = .{ .history = 0 }, + .end = .{ .history = history_max -| 1 }, + .unwrap = true, + }); + } } // Get the final path