diff options
author | Blaž Hrastnik | 2021-10-22 03:07:41 +0000 |
---|---|---|
committer | Blaž Hrastnik | 2021-10-22 03:15:18 +0000 |
commit | 182a59b5528075c0171756bff71275db8a7995f0 (patch) | |
tree | 1f477382ef5ec5e6764d98d680f0fd9fc0e06fb6 /helix-term/src/ui/picker.rs | |
parent | 3b032e8e1fd342261b153aeb375f9c0e8d882b34 (diff) |
Update to rust 1.56 + 2021 edition
Diffstat (limited to 'helix-term/src/ui/picker.rs')
-rw-r--r-- | helix-term/src/ui/picker.rs | 23 |
1 files changed, 7 insertions, 16 deletions
diff --git a/helix-term/src/ui/picker.rs b/helix-term/src/ui/picker.rs index 6f584178..1f08cf13 100644 --- a/helix-term/src/ui/picker.rs +++ b/helix-term/src/ui/picker.rs @@ -233,37 +233,28 @@ impl<T> Picker<T> { } pub fn score(&mut self) { - // need to borrow via pattern match otherwise it complains about simultaneous borrow - let Self { - ref mut matcher, - ref mut matches, - ref filters, - ref format_fn, - .. - } = *self; - let pattern = &self.prompt.line; // reuse the matches allocation - matches.clear(); - matches.extend( + self.matches.clear(); + self.matches.extend( self.options .iter() .enumerate() .filter_map(|(index, option)| { // filter options first before matching - if !filters.is_empty() { - filters.binary_search(&index).ok()?; + if !self.filters.is_empty() { + self.filters.binary_search(&index).ok()?; } // TODO: maybe using format_fn isn't the best idea here - let text = (format_fn)(option); + let text = (self.format_fn)(option); // TODO: using fuzzy_indices could give us the char idx for match highlighting - matcher + self.matcher .fuzzy_match(&text, pattern) .map(|score| (index, score)) }), ); - matches.sort_unstable_by_key(|(_, score)| -score); + self.matches.sort_unstable_by_key(|(_, score)| -score); // reset cursor position self.cursor = 0; |