diff options
author | Kirill Chibisov <contact@kchibisov.com> | 2025-01-08 17:26:48 +0300 |
---|---|---|
committer | Kirill Chibisov <contact@kchibisov.com> | 2025-01-09 05:25:53 +0300 |
commit | 8833551b0da3fdace94e1e6c07c6f57f45d9065e (patch) | |
tree | 2857163683605ac11df9a89aa9cd25f4de3ddee7 | |
parent | a26174890e2184fa29b68fde7b72de5a566ad711 (diff) | |
download | r-alacritty-8833551b0da3fdace94e1e6c07c6f57f45d9065e.tar.gz r-alacritty-8833551b0da3fdace94e1e6c07c6f57f45d9065e.tar.bz2 r-alacritty-8833551b0da3fdace94e1e6c07c6f57f45d9065e.zip |
Fix crash during live output search
Sometimes points could end up outside of viewport, thus the screen
will need to be invalidated. The default unwrapping does handle both
cases.
Fixes: a1ed79bd2c01 (Fix highlight invalidation on grid scroll)
-rw-r--r-- | alacritty/src/display/mod.rs | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/alacritty/src/display/mod.rs b/alacritty/src/display/mod.rs index 4211da5f..6c685a2a 100644 --- a/alacritty/src/display/mod.rs +++ b/alacritty/src/display/mod.rs @@ -1349,6 +1349,8 @@ impl Display { (&mut self.highlighted_hint, &mut self.highlighted_hint_age, true), (&mut self.vi_highlighted_hint, &mut self.vi_highlighted_hint_age, false), ]; + + let num_lines = self.size_info.screen_lines(); for (hint, hint_age, reset_mouse) in hints { let (start, end) = match hint { Some(hint) => (*hint.bounds().start(), *hint.bounds().end()), @@ -1362,10 +1364,12 @@ impl Display { } // Convert hint bounds to viewport coordinates. - let start = term::point_to_viewport(display_offset, start).unwrap_or_default(); - let end = term::point_to_viewport(display_offset, end).unwrap_or_else(|| { - Point::new(self.size_info.screen_lines() - 1, self.size_info.last_column()) - }); + let start = term::point_to_viewport(display_offset, start) + .filter(|point| point.line < num_lines) + .unwrap_or_default(); + let end = term::point_to_viewport(display_offset, end) + .filter(|point| point.line < num_lines) + .unwrap_or_else(|| Point::new(num_lines - 1, self.size_info.last_column())); // Clear invalidated hints. if frame.intersects(start, end) { |