fix: Wrap around the top of the picker menu when scrolling
Forgot to port the improvements in menu.rs Fixes #734
This commit is contained in:
parent
b02d872938
commit
c7d6e4461f
1 changed files with 6 additions and 8 deletions
|
@ -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> {
|
||||
|
|
Loading…
Add table
Reference in a new issue