mirror of
https://github.com/ilyakooo0/helix.git
synced 2024-12-01 11:23:10 +03:00
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
@ -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…
Reference in New Issue
Block a user