mirror of
https://github.com/helix-editor/helix.git
synced 2024-11-25 10:56:19 +04:00
fix: ui/menu: Don't allow scrolling past the end of completion
Fixes #472
This commit is contained in:
parent
e5d438705b
commit
1789dfabfe
@ -90,13 +90,13 @@ pub fn score(&mut self, pattern: &str) {
|
||||
|
||||
pub fn move_up(&mut self) {
|
||||
// TODO: wrap around to end
|
||||
let pos = self.cursor.map_or(0, |i| i.saturating_sub(1)) % self.options.len();
|
||||
let pos = self.cursor.map_or(0, |i| i.saturating_sub(1)) % self.matches.len();
|
||||
self.cursor = Some(pos);
|
||||
self.adjust_scroll();
|
||||
}
|
||||
|
||||
pub fn move_down(&mut self) {
|
||||
let pos = self.cursor.map_or(0, |i| i + 1) % self.options.len();
|
||||
let pos = self.cursor.map_or(0, |i| i + 1) % self.matches.len();
|
||||
self.cursor = Some(pos);
|
||||
self.adjust_scroll();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user