From 65bff1878ff68698da021b4d5aa00d1cfad41d0a Mon Sep 17 00:00:00 2001 From: Christian Duerr Date: Mon, 6 Jul 2020 19:10:06 +0000 Subject: Fix saved cursor handling This resolves several problems with handling of the saved cursor when switching between primary and alternate screen. Additionally ref-tests are also added for all common interactions to make sure the behavior does not regress. The behavior is based on XTerm's behavior except for interaction with `reset`. XTerm does not reset the alternate screen's saved cursor on `reset`, but VTE does. Since a `reset` should reset as much as possible, Alacritty copies VTE here instead of XTerm. --- alacritty_terminal/src/term/mod.rs | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) (limited to 'alacritty_terminal/src') diff --git a/alacritty_terminal/src/term/mod.rs b/alacritty_terminal/src/term/mod.rs index a1f816b6..996f6809 100644 --- a/alacritty_terminal/src/term/mod.rs +++ b/alacritty_terminal/src/term/mod.rs @@ -1062,18 +1062,16 @@ impl Term { /// Swap primary and alternate screen buffer. pub fn swap_alt(&mut self) { - if self.mode.contains(TermMode::ALT_SCREEN) { - let template = self.grid.cursor.template; - self.grid.region_mut(..).each(|c| c.reset(&template)); + if !self.mode.contains(TermMode::ALT_SCREEN) { + // Set alt screen cursor to the current primary screen cursor. + self.inactive_grid.cursor = self.grid.cursor; - self.inactive_grid.cursor = self.inactive_grid.saved_cursor; - self.grid.cursor = self.grid.saved_cursor; - } else { - self.inactive_grid.saved_cursor = self.inactive_grid.cursor; + // Drop information about the primary screens saved cursor. self.grid.saved_cursor = self.grid.cursor; - // Reset wrapline status flag. - self.inactive_grid.cursor.input_needs_wrap = false; + // Reset alternate screen contents. + let template = self.inactive_grid.cursor.template; + self.inactive_grid.region_mut(..).each(|c| c.reset(&template)); } mem::swap(&mut self.grid, &mut self.inactive_grid); -- cgit