diff options
author | Christian Duerr <contact@christianduerr.com> | 2020-07-06 19:10:06 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-07-06 19:10:06 +0000 |
commit | 65bff1878ff68698da021b4d5aa00d1cfad41d0a (patch) | |
tree | 0bf0ae10dd72718ce958bfd199ee973c40adc9f7 /alacritty_terminal/src/term | |
parent | 72c916ff434e23d44e2a31e6a8d5f7b8ae649008 (diff) |
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.
Diffstat (limited to 'alacritty_terminal/src/term')
-rw-r--r-- | alacritty_terminal/src/term/mod.rs | 16 |
1 files changed, 7 insertions, 9 deletions
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<T> Term<T> { /// 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); |