diff options
author | Blaž Hrastnik | 2021-09-17 05:34:59 +0000 |
---|---|---|
committer | Blaž Hrastnik | 2021-09-17 05:43:06 +0000 |
commit | c7d6e4461f249108189cddf44b487b4c71c5520a (patch) | |
tree | 5a2bc18a5dd4bc45b38b8374348521fb0354c77e /helix-term | |
parent | b02d872938395566c82658c54a22449b2c968beb (diff) |
fix: Wrap around the top of the picker menu when scrolling
Forgot to port the improvements in menu.rs
Fixes #734
Diffstat (limited to 'helix-term')
-rw-r--r-- | helix-term/src/ui/picker.rs | 14 |
1 files changed, 6 insertions, 8 deletions
diff --git a/helix-term/src/ui/picker.rs b/helix-term/src/ui/picker.rs index e040e0ff..c5b90a9c 100644 --- a/helix-term/src/ui/picker.rs +++ b/helix-term/src/ui/picker.rs @@ -270,17 +270,15 @@ impl<T> Picker<T> { } pub fn move_up(&mut self) { - self.cursor = self.cursor.saturating_sub(1); + let len = self.matches.len(); + let pos = ((self.cursor + len.saturating_sub(1)) % len) % len; + self.cursor = pos; } pub fn move_down(&mut self) { - if self.matches.is_empty() { - return; - } - - if self.cursor < self.matches.len() - 1 { - self.cursor += 1; - } + let len = self.matches.len(); + let pos = (self.cursor + 1) % len; + self.cursor = pos; } pub fn selection(&self) -> Option<&T> { |