Fix selection glitch

This commit is contained in:
Ferran Basora 2019-03-12 22:17:06 +00:00
parent 84f61085c5
commit 4a9d916a2b

View File

@ -51,20 +51,23 @@ impl<'a> View<'a> {
rustbox.set_output_mode(OutputMode::EightBit); rustbox.set_output_mode(OutputMode::EightBit);
for (index, line) in self.state.lines.iter().enumerate() {
let clean = line.trim_end_matches(|c: char| c.is_whitespace());
if clean.len() > 0 {
rustbox.print(0, index, rustbox::RB_NORMAL, Color::White, Color::Black, line);
}
}
let mut typed_hint: String = "".to_owned(); let mut typed_hint: String = "".to_owned();
let matches = self.state.matches(self.reverse, self.unique); let matches = self.state.matches(self.reverse, self.unique);
let longest_hint = matches.iter().filter_map(|m| m.hint.clone()).max_by(|x, y| x.len().cmp(&y.len())).unwrap().clone(); 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; let mut selected;
loop { loop {
rustbox.clear();
rustbox.present();
for (index, line) in self.state.lines.iter().enumerate() {
let clean = line.trim_end_matches(|c: char| c.is_whitespace());
if clean.len() > 0 {
rustbox.print(0, index, rustbox::RB_NORMAL, Color::White, Color::Black, format!("{}\n", line).to_string().as_str());
}
}
selected = matches.last(); selected = matches.last();
match matches.iter().enumerate().find(|&h| h.0 == self.skip) { match matches.iter().enumerate().find(|&h| h.0 == self.skip) {