Fix multi selection

This commit is contained in:
Ferran Basora 2020-11-28 16:22:21 +00:00
parent ee850b2282
commit 9255c86797

View File

@ -182,16 +182,6 @@ impl<'a> View<'a> {
break; break;
} }
} }
Key::Insert => match self.matches.iter().enumerate().find(|&h| h.0 == self.skip) {
Some(hm) => {
chosen.push((hm.1.text.to_string(), false));
if !self.multi {
return CaptureEvent::Hint(chosen);
}
}
_ => panic!("Match not found?"),
},
Key::Up => { Key::Up => {
self.prev(); self.prev();
} }
@ -205,6 +195,19 @@ impl<'a> View<'a> {
self.next(); self.next();
} }
Key::Char(ch) => { Key::Char(ch) => {
if ch == '\n' {
match self.matches.iter().enumerate().find(|&h| h.0 == self.skip) {
Some(hm) => {
chosen.push((hm.1.text.to_string(), false));
if !self.multi {
return CaptureEvent::Hint(chosen);
}
}
_ => panic!("Match not found?"),
}
}
if ch == ' ' && self.multi { if ch == ' ' && self.multi {
return CaptureEvent::Hint(chosen); return CaptureEvent::Hint(chosen);
} }