move_up will select last item, when no item selected (#907)
commitb142fd4080d99a7e4f39bb06207ded6771d47b20
authorCossonLeo <20379044+cossonleo@users.noreply.github.com>
dateTue 26 Oct 2021, 08:42 (5 years ago)
parentbca98b5
helix-term/src/ui/menu.rs+2−1
@@ -98,7 +98,8 @@ impl<T: Item> Menu<T> {
9898
9999 pub fn move_up(&mut self) {
100100 let len = self.matches.len();
101− let pos = self.cursor.map_or(0, |i| (i + len.saturating_sub(1)) % len) % len;
101+ let max_index = len.saturating_sub(1);
102+ let pos = self.cursor.map_or(max_index, |i| (i + max_index) % len) % len;
102103 self.cursor = Some(pos);
103104 self.adjust_scroll();
104105 }