diff options
author | Christian Duerr <chrisduerr@users.noreply.github.com> | 2019-03-02 21:30:29 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-03-02 21:30:29 +0000 |
commit | de52ddb6c25a6d58cdfaa095ad6ec9abffa6564a (patch) | |
tree | ee40404604fa757f62844cab715eb14b6cbfc134 /src/grid/mod.rs | |
parent | 9468b50b75be13d6b0d36ba2c01d36d92f008bf2 (diff) | |
download | alacritty-de52ddb6c25a6d58cdfaa095ad6ec9abffa6564a.tar.gz alacritty-de52ddb6c25a6d58cdfaa095ad6ec9abffa6564a.zip |
Fix alt screen bugs
This fixes two bugs with the alternate screen buffer.
When resetting while in the alt screen, Alacritty would not swap out
the grids leading to scrollback getting disabled. By swapping out the
grids again when resetting in the alternate screen buffer, scrollback is
now unaffected from a reset.
There was another issue with the cursor jumping around when leaving the
alt screen even though it was not active, this was fixed by skipping all
alt screen swap routines unless the current state matches the expected
state.
This fixes #2145.
Diffstat (limited to 'src/grid/mod.rs')
-rw-r--r-- | src/grid/mod.rs | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/src/grid/mod.rs b/src/grid/mod.rs index 7766f9a9..80289cd6 100644 --- a/src/grid/mod.rs +++ b/src/grid/mod.rs @@ -404,6 +404,22 @@ impl<T: Copy + Clone> Grid<T> { } } } + + // Completely reset the grid state + pub fn reset(&mut self, template: &T) { + // Explicitly purge all lines from history + let shrinkage = self.raw.len() - self.lines.0; + self.raw.shrink_lines(shrinkage); + self.clear_history(); + + // Reset all visible lines + for row in 0..self.raw.len() { + self.raw[row].reset(template); + } + + self.display_offset = 0; + self.selection = None; + } } #[allow(clippy::len_without_is_empty)] |