summaryrefslogtreecommitdiff
path: root/helix-term/src/ui
diff options
context:
space:
mode:
authorBlaž Hrastnik2021-09-17 05:34:59 +0000
committerBlaž Hrastnik2021-09-17 05:43:06 +0000
commitc7d6e4461f249108189cddf44b487b4c71c5520a (patch)
tree5a2bc18a5dd4bc45b38b8374348521fb0354c77e /helix-term/src/ui
parentb02d872938395566c82658c54a22449b2c968beb (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/src/ui')
-rw-r--r--helix-term/src/ui/picker.rs14
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> {