1
0
Fork 0
mirror of https://github.com/alacritty/alacritty.git synced 2024-11-11 13:51:01 -05:00

Keep viewport in place during resize

Fixes #4879.

Co-authored-by: Christian Duerr <contact@christianduerr.com>
This commit is contained in:
Richard Steinmetz 2021-03-31 21:11:16 +02:00 committed by GitHub
parent 3bd5ac221a
commit 58cae8f2ed
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 8 additions and 2 deletions

View file

@ -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

View file

@ -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())
}
}

View file

@ -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;
}
}
}
}