Fix bug in selection navigation

This commit is contained in:
Ferran Basora 2019-03-12 22:27:21 +00:00
parent b875a37ded
commit 45d15bf03a

View File

@ -39,9 +39,11 @@ impl<'a> View<'a> {
}
}
pub fn next(&mut self) {
pub fn next(&mut self, maximum: usize) {
if self.skip < maximum {
self.skip = self.skip + 1;
}
}
pub fn present(&mut self) -> Option<(String, bool)> {
let mut rustbox = match RustBox::init(Default::default()) {
@ -114,9 +116,9 @@ impl<'a> View<'a> {
}
}
Key::Up => { self.prev(); }
Key::Down => { self.next(); }
Key::Down => { self.next(matches.len() - 1); }
Key::Left => { self.prev(); }
Key::Right => { self.next(); }
Key::Right => { self.next(matches.len() - 1); }
Key::Char(ch) => {
let key = ch.to_string();
let lower_key = key.to_lowercase();