aboutsummaryrefslogtreecommitdiff
path: root/helix-term
diff options
context:
space:
mode:
Diffstat (limited to 'helix-term')
-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> {