From 58cae8f2edf44e6bf0721543c61edb57bdf7d776 Mon Sep 17 00:00:00 2001 From: Richard Steinmetz Date: Wed, 31 Mar 2021 21:11:16 +0200 Subject: Keep viewport in place during resize Fixes #4879. Co-authored-by: Christian Duerr --- alacritty_terminal/src/grid/resize.rs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'alacritty_terminal/src/grid/resize.rs') 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; + } } } } -- cgit v1.2.3-54-g00ecf