From edd261f5ea9551a1c5fcfd2354e7b04d7237eebc Mon Sep 17 00:00:00 2001 From: Speak2Erase Date: Sat, 23 Mar 2024 22:31:59 -0700 Subject: [PATCH] Fix scrolling --- crates/term/src/widget/mod.rs | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/crates/term/src/widget/mod.rs b/crates/term/src/widget/mod.rs index fc32d529..e19fa714 100644 --- a/crates/term/src/widget/mod.rs +++ b/crates/term/src/widget/mod.rs @@ -143,12 +143,14 @@ where self.backend.with_term(|term| { term.grid_mut().clear_history(); }); + self.layout_job = Default::default(); } pub fn erase_scrollback_and_viewport(&mut self) { self.backend.with_term(|term| { term.grid_mut().reset(); }); + self.layout_job = Default::default(); } pub fn update(&mut self) { @@ -282,18 +284,19 @@ where let (screen_columns, screen_lines, total_lines, display_offset, cursor_style, cursor_point) = self.backend.with_term(|term| { match term.damage() { - TermDamage::Full => { + // we only do partial repaints if the layout job is empty + TermDamage::Partial(damage) if !self.layout_job.is_empty() => { + // We have to collect here to avoid borrowing the terminal mutably twice (even though it isn't, really) + let damage = damage.collect::>(); + Self::layout_job_damage(&mut self.layout_job, config, term.grid(), damage) + } + _ => { self.layout_job = Self::layout_job_full( term.columns(), config, term.renderable_content().display_iter, ); } - TermDamage::Partial(damage) => { - // We have to collect here to avoid borrowing the terminal mutably twice (even though it isn't, really) - let damage = damage.collect::>(); - Self::layout_job_damage(&mut self.layout_job, config, term.grid(), damage) - } } term.reset_damage(); @@ -518,6 +521,7 @@ where term.grid_mut() .scroll_display(alacritty_terminal::grid::Scroll::Delta(delta)); }); + self.layout_job = Default::default(); } } @@ -623,7 +627,8 @@ where if term_modified { self.backend.with_term(|term| { term.scroll_display(alacritty_terminal::grid::Scroll::Bottom); - }) + }); + self.layout_job = Default::default(); } }