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,8 +39,10 @@ impl<'a> View<'a> {
} }
} }
pub fn next(&mut self) { pub fn next(&mut self, maximum: usize) {
self.skip = self.skip + 1; if self.skip < maximum {
self.skip = self.skip + 1;
}
} }
pub fn present(&mut self) -> Option<(String, bool)> { pub fn present(&mut self) -> Option<(String, bool)> {
@ -114,9 +116,9 @@ impl<'a> View<'a> {
} }
} }
Key::Up => { self.prev(); } Key::Up => { self.prev(); }
Key::Down => { self.next(); } Key::Down => { self.next(matches.len() - 1); }
Key::Left => { self.prev(); } Key::Left => { self.prev(); }
Key::Right => { self.next(); } Key::Right => { self.next(matches.len() - 1); }
Key::Char(ch) => { Key::Char(ch) => {
let key = ch.to_string(); let key = ch.to_string();
let lower_key = key.to_lowercase(); let lower_key = key.to_lowercase();