From ffb8979125d70ddc64af72a6bbfa63ff8a992b18 Mon Sep 17 00:00:00 2001 From: Aram Drevekenin Date: Sun, 1 Nov 2020 09:57:34 +0100 Subject: [PATCH] fix(scrolling): move clear scroll to scroll so that it works --- src/screen.rs | 5 +---- src/terminal_pane.rs | 11 +++++------ 2 files changed, 6 insertions(+), 10 deletions(-) diff --git a/src/screen.rs b/src/screen.rs index b4f2955b..19fef9b2 100644 --- a/src/screen.rs +++ b/src/screen.rs @@ -965,10 +965,7 @@ impl Screen { pub fn clear_active_terminal_scroll(&mut self) { if let Some(active_terminal_id) = self.get_active_terminal_id() { let active_terminal = self.terminals.get_mut(&active_terminal_id).unwrap(); - if active_terminal.scroll_up_count.is_some() { - active_terminal.clear_scroll(); - self.render(); - } + active_terminal.clear_scroll(); } } } diff --git a/src/terminal_pane.rs b/src/terminal_pane.rs index 0bd384f4..b6a1ad13 100644 --- a/src/terminal_pane.rs +++ b/src/terminal_pane.rs @@ -966,6 +966,9 @@ impl Scroll { } } } + pub fn reset_viewport (&mut self) { + self.viewport_bottom_offset = None; + } } impl Debug for Scroll { @@ -983,7 +986,6 @@ pub struct TerminalOutput { pub display_rows: u16, pub display_cols: u16, pub should_render: bool, - pub scroll_up_count: Option, pub x_coords: u16, pub y_coords: u16, pending_foreground_code: Option, @@ -1023,7 +1025,6 @@ impl TerminalOutput { display_rows: ws.ws_row, display_cols: ws.ws_col, should_render: true, - scroll_up_count: None, pending_foreground_code: None, pending_background_code: None, pending_bold_code: None, @@ -1167,10 +1168,8 @@ impl TerminalOutput { self.should_render = true; } pub fn clear_scroll(&mut self) { - if self.scroll_up_count.is_some() { - self.should_render = true; - } - self.scroll_up_count = None; + self.scroll.reset_viewport(); + self.should_render = true; } fn add_newline (&mut self) { self.scroll.add_canonical_line(); // TODO: handle scroll region