diff --git a/src/server/listener.rs b/src/server/listener.rs index 75520a973..884216e08 100644 --- a/src/server/listener.rs +++ b/src/server/listener.rs @@ -394,6 +394,13 @@ fn maybe_push_tab_changes( ) { dirty_rows.add(idx); } + // Make sure we pick up "damage" done by switching between alt and primary screen + for idx in tab + .renderer() + .get_dirty_lines(0..dims.viewport_rows as StableRowIndex) + { + dirty_rows.add(idx); + } let dirty_lines = dirty_rows.iter().cloned().collect(); diff --git a/term/src/terminalstate.rs b/term/src/terminalstate.rs index ab1ed8bce..ddbc2eb70 100644 --- a/term/src/terminalstate.rs +++ b/term/src/terminalstate.rs @@ -125,10 +125,23 @@ impl ScreenOrAlt { pub fn activate_alt_screen(&mut self) { self.alt_screen_is_active = true; + self.dirty_top_phys_rows(); } pub fn activate_primary_screen(&mut self) { self.alt_screen_is_active = false; + self.dirty_top_phys_rows(); + } + + // When switching between alt and primary screen, we implicitly change + // the content associated with StableRowIndex 0..num_rows. The muxer + // use case needs to know to invalidate its cache, so we mark those rows + // as dirty. + fn dirty_top_phys_rows(&mut self) { + let num_rows = self.screen.physical_rows; + for line_idx in 0..num_rows { + self.screen.line_mut(line_idx).set_dirty(); + } } pub fn is_alt_screen_active(&self) -> bool {