From c828ff39d7c4baef28cc352f36bf00214b2daa35 Mon Sep 17 00:00:00 2001 From: Ferran Basora Date: Tue, 12 Mar 2019 22:41:42 +0000 Subject: [PATCH] Fix bug with reverse navigation --- src/view.rs | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/src/view.rs b/src/view.rs index 168628c..3ad3233 100644 --- a/src/view.rs +++ b/src/view.rs @@ -58,6 +58,8 @@ impl<'a> View<'a> { let longest_hint = matches.iter().filter_map(|m| m.hint.clone()).max_by(|x, y| x.len().cmp(&y.len())).unwrap().clone(); let mut selected; + self.skip = if self.reverse { matches.len() - 1 } else { 0 }; + loop { rustbox.clear(); rustbox.present(); @@ -70,14 +72,7 @@ impl<'a> View<'a> { } } - selected = matches.last(); - - match matches.iter().enumerate().find(|&h| h.0 == self.skip) { - Some(hm) => { - selected = Some(hm.1); - } - _ => {} - } + selected = matches.get(self.skip); for mat in matches.iter() { let selected_color = if selected == Some(mat) {