From f5b0821860940782567a0baa17280aef04f845e3 Mon Sep 17 00:00:00 2001 From: Mathis Brossier Date: Sun, 16 Jan 2022 02:55:28 +0100 Subject: Fix panics when resizing (#1408) * Change buffer.get & buffer.get_mut to return Option, Implement Trait Index & IndexMut to panic * Prevent FilePicker from drawing outside buffer (rust panics) * apply suggestion * add function in_bounds to avoid useless calculations Co-authored-by: mathis --- helix-term/src/ui/menu.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'helix-term/src/ui/menu.rs') diff --git a/helix-term/src/ui/menu.rs b/helix-term/src/ui/menu.rs index 69053db3..9758732c 100644 --- a/helix-term/src/ui/menu.rs +++ b/helix-term/src/ui/menu.rs @@ -301,7 +301,7 @@ impl Component for Menu { let is_marked = i >= scroll_line && i < scroll_line + scroll_height; if is_marked { - let cell = surface.get_mut(area.x + area.width - 2, area.y + i as u16); + let cell = &mut surface[(area.x + area.width - 2, area.y + i as u16)]; cell.set_symbol("▐ "); // cell.set_style(selected); // cell.set_style(if is_marked { selected } else { style }); -- cgit v1.2.3-70-g09d2