mirror of
https://github.com/alacritty/alacritty.git
synced 2024-11-18 13:55:23 -05:00
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.
This commit is contained in:
parent
9468b50b75
commit
b7ed0855bf
4 changed files with 31 additions and 10 deletions
|
@ -17,6 +17,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
||||||
- Automatic copying of selection to clipboard when mouse is released outside of Alacritty
|
- Automatic copying of selection to clipboard when mouse is released outside of Alacritty
|
||||||
- Scrollback history live reload only working when shrinking lines
|
- Scrollback history live reload only working when shrinking lines
|
||||||
- Crash when decreasing scrollback history in config while scrolled in history
|
- Crash when decreasing scrollback history in config while scrolled in history
|
||||||
|
- Resetting the terminal while in the alt screen will no longer disable scrollback
|
||||||
|
- Cursor jumping around when leaving alt screen while not in the alt screen
|
||||||
|
- Text lingering around when resetting while scrolled up in the history
|
||||||
|
|
||||||
## Version 0.2.9
|
## Version 0.2.9
|
||||||
|
|
||||||
|
|
|
@ -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)]
|
#[allow(clippy::len_without_is_empty)]
|
||||||
|
|
|
@ -160,7 +160,7 @@ impl<T> Storage<T> {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Shrink the number of lines in the buffer
|
// Shrink the number of lines in the buffer
|
||||||
fn shrink_lines(&mut self, shrinkage: usize) {
|
pub fn shrink_lines(&mut self, shrinkage: usize) {
|
||||||
self.len -= shrinkage;
|
self.len -= shrinkage;
|
||||||
|
|
||||||
// Free memory
|
// Free memory
|
||||||
|
|
|
@ -1915,10 +1915,12 @@ impl ansi::Handler for Term {
|
||||||
// Reset all important fields in the term struct
|
// Reset all important fields in the term struct
|
||||||
#[inline]
|
#[inline]
|
||||||
fn reset_state(&mut self) {
|
fn reset_state(&mut self) {
|
||||||
|
if self.alt {
|
||||||
|
self.swap_alt();
|
||||||
|
}
|
||||||
self.input_needs_wrap = false;
|
self.input_needs_wrap = false;
|
||||||
self.next_title = None;
|
self.next_title = None;
|
||||||
self.next_mouse_cursor = None;
|
self.next_mouse_cursor = None;
|
||||||
self.alt = false;
|
|
||||||
self.cursor = Default::default();
|
self.cursor = Default::default();
|
||||||
self.active_charset = Default::default();
|
self.active_charset = Default::default();
|
||||||
self.mode = Default::default();
|
self.mode = Default::default();
|
||||||
|
@ -1929,8 +1931,8 @@ impl ansi::Handler for Term {
|
||||||
self.colors = self.original_colors;
|
self.colors = self.original_colors;
|
||||||
self.color_modified = [false; color::COUNT];
|
self.color_modified = [false; color::COUNT];
|
||||||
self.cursor_style = None;
|
self.cursor_style = None;
|
||||||
self.grid.clear_history();
|
self.grid.reset(&Cell::default());
|
||||||
self.grid.region_mut(..).each(|c| c.reset(&Cell::default()));
|
self.alt_grid.reset(&Cell::default());
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
|
@ -1981,12 +1983,12 @@ impl ansi::Handler for Term {
|
||||||
trace!("Setting mode: {:?}", mode);
|
trace!("Setting mode: {:?}", mode);
|
||||||
match mode {
|
match mode {
|
||||||
ansi::Mode::SwapScreenAndSetRestoreCursor => {
|
ansi::Mode::SwapScreenAndSetRestoreCursor => {
|
||||||
self.mode.insert(mode::TermMode::ALT_SCREEN);
|
|
||||||
self.save_cursor_position();
|
|
||||||
if !self.alt {
|
if !self.alt {
|
||||||
|
self.mode.insert(mode::TermMode::ALT_SCREEN);
|
||||||
|
self.save_cursor_position();
|
||||||
self.swap_alt();
|
self.swap_alt();
|
||||||
|
self.save_cursor_position();
|
||||||
}
|
}
|
||||||
self.save_cursor_position();
|
|
||||||
},
|
},
|
||||||
ansi::Mode::ShowCursor => self.mode.insert(mode::TermMode::SHOW_CURSOR),
|
ansi::Mode::ShowCursor => self.mode.insert(mode::TermMode::SHOW_CURSOR),
|
||||||
ansi::Mode::CursorKeys => self.mode.insert(mode::TermMode::APP_CURSOR),
|
ansi::Mode::CursorKeys => self.mode.insert(mode::TermMode::APP_CURSOR),
|
||||||
|
@ -2021,12 +2023,12 @@ impl ansi::Handler for Term {
|
||||||
trace!("Unsetting mode: {:?}", mode);
|
trace!("Unsetting mode: {:?}", mode);
|
||||||
match mode {
|
match mode {
|
||||||
ansi::Mode::SwapScreenAndSetRestoreCursor => {
|
ansi::Mode::SwapScreenAndSetRestoreCursor => {
|
||||||
self.mode.remove(mode::TermMode::ALT_SCREEN);
|
|
||||||
self.restore_cursor_position();
|
|
||||||
if self.alt {
|
if self.alt {
|
||||||
|
self.mode.remove(mode::TermMode::ALT_SCREEN);
|
||||||
|
self.restore_cursor_position();
|
||||||
self.swap_alt();
|
self.swap_alt();
|
||||||
|
self.restore_cursor_position();
|
||||||
}
|
}
|
||||||
self.restore_cursor_position();
|
|
||||||
},
|
},
|
||||||
ansi::Mode::ShowCursor => self.mode.remove(mode::TermMode::SHOW_CURSOR),
|
ansi::Mode::ShowCursor => self.mode.remove(mode::TermMode::SHOW_CURSOR),
|
||||||
ansi::Mode::CursorKeys => self.mode.remove(mode::TermMode::APP_CURSOR),
|
ansi::Mode::CursorKeys => self.mode.remove(mode::TermMode::APP_CURSOR),
|
||||||
|
|
Loading…
Reference in a new issue