fix(scroll): reset scroll properly when typing (#1547)

This commit is contained in:
Aram Drevekenin 2022-06-27 19:01:33 +02:00 committed by GitHub
parent 9225ce6c34
commit 7c1348572a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -854,14 +854,14 @@ impl Grid {
self.output_buffer.update_all_lines();
}
pub fn reset_viewport(&mut self) {
let row_count_below = self.lines_below.len();
for _ in 0..row_count_below {
let max_lines_to_scroll = *SCROLL_BUFFER_SIZE.get().unwrap() * 2; // while not very elegant, this can prevent minor bugs from becoming showstoppers by sticking the whole app display in an endless loop
let mut lines_scrolled = 0;
while self.is_scrolled && lines_scrolled < max_lines_to_scroll {
self.scroll_down_one_line();
lines_scrolled += 1;
}
if row_count_below > 0 {
self.output_buffer.update_all_lines();
}
}
pub fn rotate_scroll_region_up(&mut self, count: usize) {
if let Some((scroll_region_top, scroll_region_bottom)) = self
.scroll_region