From ef2aed7971340de0dbf1e426aec5ecb6ab203278 Mon Sep 17 00:00:00 2001 From: 5-pebbles <5-pebble@protonmail.com> Date: Fri, 3 May 2024 03:03:13 +0000 Subject: [PATCH] fix(menu): prevent panic on scrolling beyond buffer limits; --- helix-term/src/ui/menu.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/helix-term/src/ui/menu.rs b/helix-term/src/ui/menu.rs index c5006f9580af..42d321bbb3d0 100644 --- a/helix-term/src/ui/menu.rs +++ b/helix-term/src/ui/menu.rs @@ -379,9 +379,10 @@ impl Component for Menu { let render_borders = cx.editor.menu_border(); + // this highlights the selected edges if there are no borders if !render_borders { if let Some(cursor) = self.cursor { - let offset_from_top = cursor - scroll; + let offset_from_top = (cursor - scroll).min(area.height as usize - 1).max(0); let left = &mut surface[(area.left(), area.y + offset_from_top as u16)]; left.set_style(selected); let right = &mut surface[(