Completions

This commit is contained in:
Armin Friedl 2021-11-08 22:13:22 +01:00
parent 9fc30022ec
commit a207a38101

View file

@ -86,6 +86,10 @@ impl Roftl {
}
pub fn narrow(&mut self, input: &str) -> Vec<(&Entry, Vec<usize>)> {
let mut completions = std::collections::HashMap::new();
completions.insert("e", "emacs");
completions.insert("f", "firefox");
let mut scored_entries: Vec<(f64, usize, &Entry, Vec<usize>)> = self.entries
.par_iter()
.enumerate()
@ -94,6 +98,8 @@ impl Roftl {
if input.is_empty() { return Some((0.0, idx, entry, vec![])) }
let input = completions.get(input).unwrap_or(&input);
let match_result = self.primary_matcher.try_match(&entry.name, input);
return match_result.map(|(score, indices)| (score, idx, entry, indices) )
})