diff options
author | Richard Steinmetz <richard@steinmetz.cloud> | 2021-03-31 21:11:16 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-03-31 19:11:16 +0000 |
commit | 58cae8f2edf44e6bf0721543c61edb57bdf7d776 (patch) | |
tree | 4f20cae7d3069ccc8e03ffee514a5d0605f85b9e | |
parent | 3bd5ac221ab3b122962063edd1f4c10f9f2d117f (diff) | |
download | alacritty-58cae8f2edf44e6bf0721543c61edb57bdf7d776.tar.gz alacritty-58cae8f2edf44e6bf0721543c61edb57bdf7d776.zip |
Keep viewport in place during resize
Fixes #4879.
Co-authored-by: Christian Duerr <contact@christianduerr.com>
-rw-r--r-- | CHANGELOG.md | 1 | ||||
-rw-r--r-- | alacritty_terminal/src/grid/mod.rs | 2 | ||||
-rw-r--r-- | alacritty_terminal/src/grid/resize.rs | 7 |
3 files changed, 8 insertions, 2 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md index 34f2928e..39b3ebad 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -24,6 +24,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). - Incorrect vi cursor position after leaving search - Clicking on URLs on Windows incorrectly opens File Explorer - Incorrect underline cursor thickness on wide cell +- Viewport moving around when resizing while scrolled into history ### Removed diff --git a/alacritty_terminal/src/grid/mod.rs b/alacritty_terminal/src/grid/mod.rs index 169067af..06af3bea 100644 --- a/alacritty_terminal/src/grid/mod.rs +++ b/alacritty_terminal/src/grid/mod.rs @@ -502,7 +502,7 @@ pub trait Dimensions { /// Number of invisible lines part of the scrollback history. #[inline] fn history_size(&self) -> usize { - self.total_lines() - self.screen_lines() + self.total_lines().saturating_sub(self.screen_lines()) } } diff --git a/alacritty_terminal/src/grid/resize.rs b/alacritty_terminal/src/grid/resize.rs index eb8bef0c..10bc51f9 100644 --- a/alacritty_terminal/src/grid/resize.rs +++ b/alacritty_terminal/src/grid/resize.rs @@ -187,7 +187,7 @@ impl<T: GridCell + Default + PartialEq + Clone> Grid<T> { cursor_line_delta += line_delta.0 as usize; } else if row.is_clear() { - if i + reversed.len() >= self.lines { + if i <= self.display_offset { // Since we removed a line, rotate down the viewport. self.display_offset = self.display_offset.saturating_sub(1); } @@ -354,6 +354,11 @@ impl<T: GridCell + Default + PartialEq + Clone> Grid<T> { wrapped.resize_with(columns, T::default); } row = Row::from_vec(wrapped, occ); + + if i <= self.display_offset { + // Since we added a new line, rotate up the viewport. + self.display_offset += 1; + } } } } |