From ec46aba0898f35b1359ccbf9dfd05f7c9eca2802 Mon Sep 17 00:00:00 2001 From: Wez Furlong Date: Sun, 24 Jul 2022 16:15:47 -0700 Subject: [PATCH] mux: prefer compressed Lines when syncing --- wezterm-mux-server-impl/src/sessionhandler.rs | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/wezterm-mux-server-impl/src/sessionhandler.rs b/wezterm-mux-server-impl/src/sessionhandler.rs index f05296d2f..a87e1fa4c 100644 --- a/wezterm-mux-server-impl/src/sessionhandler.rs +++ b/wezterm-mux-server-impl/src/sessionhandler.rs @@ -100,17 +100,20 @@ impl PerPane { let mut bonus_lines = lines .into_iter() .enumerate() - .map(|(idx, line)| { + .map(|(idx, mut line)| { let stable_row = first_line + idx as StableRowIndex; all_dirty_lines.remove(stable_row); + line.compress_for_scrollback(); (stable_row, line) }) .collect::>(); // Always send the cursor's row, as that tends to the busiest and we don't // have a sequencing concept for our idea of the remote state. - let (cursor_line, lines) = pane.get_lines(cursor_position.y..cursor_position.y + 1); - bonus_lines.push((cursor_line, lines[0].clone())); + let (cursor_line_idx, mut lines) = pane.get_lines(cursor_position.y..cursor_position.y + 1); + let mut cursor_line = lines.remove(0); + cursor_line.compress_for_scrollback(); + bonus_lines.push((cursor_line_idx, cursor_line)); self.cursor_position = cursor_position; self.title = title.clone(); @@ -587,8 +590,9 @@ impl SessionHandler { for range in lines { let (first_row, lines) = pane.get_lines(range); - for (idx, line) in lines.into_iter().enumerate() { + for (idx, mut line) in lines.into_iter().enumerate() { let stable_row = first_row + idx as StableRowIndex; + line.compress_for_scrollback(); lines_and_indices.push((stable_row, line)); } }