From 197b873deefb24e5435c3fbf88c607bb7f26c614 Mon Sep 17 00:00:00 2001 From: Danny Lin Date: Thu, 6 Jun 2024 23:46:24 -0700 Subject: [PATCH] scrollback: buffer writes to scrollback file Screen.dumpString writes one character at a time, so buffer writes to the scrollback file to speed it up. --- src/Surface.zig | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/Surface.zig b/src/Surface.zig index 354059921..42ef79a67 100644 --- a/src/Surface.zig +++ b/src/Surface.zig @@ -3201,6 +3201,8 @@ pub fn performBindingAction(self: *Surface, action: input.Binding.Action) !bool // Open our scrollback file var file = try tmp_dir.dir.createFile("scrollback", .{}); defer file.close(); + // Screen.dumpString writes byte-by-byte, so buffer it + var buf_writer = std.io.bufferedWriter(file.writer()); // Write the scrollback contents. This requires a lock. { @@ -3221,11 +3223,12 @@ pub fn performBindingAction(self: *Surface, action: input.Binding.Action) !bool if (pages.getBottomRight(.active)) |br| { const tl = pages.getTopLeft(.history); try self.io.terminal.screen.dumpString( - file.writer(), + buf_writer.writer(), .{ .tl = tl, .br = br, .unwrap = true }, ); } } + try buf_writer.flush(); // Get the final path var path_buf: [std.fs.MAX_PATH_BYTES]u8 = undefined;