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[(