From b142fd4080d99a7e4f39bb06207ded6771d47b20 Mon Sep 17 00:00:00 2001 From: CossonLeo Date: Tue, 26 Oct 2021 08:42:23 +0800 Subject: move_up will select last item, when no item selected (#907) --- helix-term/src/ui/menu.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'helix-term/src') diff --git a/helix-term/src/ui/menu.rs b/helix-term/src/ui/menu.rs index dd163d34..3c492d14 100644 --- a/helix-term/src/ui/menu.rs +++ b/helix-term/src/ui/menu.rs @@ -98,7 +98,8 @@ impl Menu { pub fn move_up(&mut self) { let len = self.matches.len(); - let pos = self.cursor.map_or(0, |i| (i + len.saturating_sub(1)) % len) % len; + let max_index = len.saturating_sub(1); + let pos = self.cursor.map_or(max_index, |i| (i + max_index) % len) % len; self.cursor = Some(pos); self.adjust_scroll(); } -- cgit v1.2.3-70-g09d2