diff options
author | CossonLeo | 2021-10-26 00:42:23 +0000 |
---|---|---|
committer | GitHub | 2021-10-26 00:42:23 +0000 |
commit | b142fd4080d99a7e4f39bb06207ded6771d47b20 (patch) | |
tree | 2acb2fbbce82374a3fb73a2b5717252cf4afd673 /helix-term/src/ui | |
parent | bca98b5bedfa6c9410384f26a2df6115874351bc (diff) |
move_up will select last item, when no item selected (#907)
Diffstat (limited to 'helix-term/src/ui')
-rw-r--r-- | helix-term/src/ui/menu.rs | 3 |
1 files changed, 2 insertions, 1 deletions
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<T: Item> Menu<T> { 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(); } |