diff --git a/wezterm-gui/src/termwindow/mod.rs b/wezterm-gui/src/termwindow/mod.rs index 56aad5642..d17d65653 100644 --- a/wezterm-gui/src/termwindow/mod.rs +++ b/wezterm-gui/src/termwindow/mod.rs @@ -939,11 +939,6 @@ impl TermWindow { } } } - - // If the model is dirty, arrange to re-paint - if self.check_for_dirty_lines_and_invalidate_selection(&pos) { - needs_invalidate = true; - } } if needs_invalidate { @@ -955,18 +950,18 @@ impl TermWindow { Ok(()) } - fn check_for_dirty_lines_and_invalidate_selection(&mut self, pos: &PositionedPane) -> bool { - let dims = pos.pane.get_dimensions(); + fn check_for_dirty_lines_and_invalidate_selection(&mut self, pane: &Rc) -> bool { + let dims = pane.get_dimensions(); let viewport = self - .get_viewport(pos.pane.pane_id()) + .get_viewport(pane.pane_id()) .unwrap_or(dims.physical_top); let visible_range = viewport..viewport + dims.viewport_rows as StableRowIndex; - let dirty = pos.pane.get_dirty_lines(visible_range); + let dirty = pane.get_dirty_lines(visible_range); if !dirty.is_empty() { - if pos.pane.downcast_ref::().is_none() - && pos.pane.downcast_ref::().is_none() - && pos.pane.downcast_ref::().is_none() + if pane.downcast_ref::().is_none() + && pane.downcast_ref::().is_none() + && pane.downcast_ref::().is_none() { // If any of the changed lines intersect with the // selection, then we need to clear the selection, but not @@ -975,18 +970,17 @@ impl TermWindow { // highlighting purpose but also manipulates the selection // and we want to allow it to retain the selection it made! - let clear_selection = if let Some(selection_range) = - self.selection(pos.pane.pane_id()).range.as_ref() - { - let selection_rows = selection_range.rows(); - selection_rows.into_iter().any(|row| dirty.contains(row)) - } else { - false - }; + let clear_selection = + if let Some(selection_range) = self.selection(pane.pane_id()).range.as_ref() { + let selection_rows = selection_range.rows(); + selection_rows.into_iter().any(|row| dirty.contains(row)) + } else { + false + }; if clear_selection { - self.selection(pos.pane.pane_id()).range.take(); - self.selection(pos.pane.pane_id()).start.take(); + self.selection(pane.pane_id()).range.take(); + self.selection(pane.pane_id()).start.take(); } } diff --git a/wezterm-gui/src/termwindow/render.rs b/wezterm-gui/src/termwindow/render.rs index 41bd5076e..3573dca72 100644 --- a/wezterm-gui/src/termwindow/render.rs +++ b/wezterm-gui/src/termwindow/render.rs @@ -151,13 +151,7 @@ impl super::TermWindow { } pub fn paint_pane_opengl(&mut self, pos: &PositionedPane) -> anyhow::Result<()> { - // We typically check this periodically in the background as part - // of deciding whether to repaint, but there are some situations - // where the model may have been marked dirty and we re-render - // very quickly. If we don't check for dirty lines here before - // we call get_lines_with_hyperlinks_applied below, then we'll - // not clear the selection when we should. - self.check_for_dirty_lines_and_invalidate_selection(pos); + self.check_for_dirty_lines_and_invalidate_selection(&pos.pane); let config = &self.config; let palette = pos.pane.palette();