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 Grid { 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 Grid { 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; + } } } }