From 8833551b0da3fdace94e1e6c07c6f57f45d9065e Mon Sep 17 00:00:00 2001 From: Kirill Chibisov Date: Wed, 8 Jan 2025 17:26:48 +0300 Subject: 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) --- alacritty/src/display/mod.rs | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'alacritty/src') 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) { -- cgit