aboutsummaryrefslogtreecommitdiff
path: root/helix-term/src/ui/menu.rs
diff options
context:
space:
mode:
authorBlaž Hrastnik2021-10-22 03:07:41 +0000
committerBlaž Hrastnik2021-10-22 03:15:18 +0000
commit182a59b5528075c0171756bff71275db8a7995f0 (patch)
tree1f477382ef5ec5e6764d98d680f0fd9fc0e06fb6 /helix-term/src/ui/menu.rs
parent3b032e8e1fd342261b153aeb375f9c0e8d882b34 (diff)
Update to rust 1.56 + 2021 edition
Diffstat (limited to 'helix-term/src/ui/menu.rs')
-rw-r--r--helix-term/src/ui/menu.rs32
1 files changed, 15 insertions, 17 deletions
diff --git a/helix-term/src/ui/menu.rs b/helix-term/src/ui/menu.rs
index 055593fd..1130089d 100644
--- a/helix-term/src/ui/menu.rs
+++ b/helix-term/src/ui/menu.rs
@@ -64,25 +64,23 @@ impl<T: Item> Menu<T> {
}
pub fn score(&mut self, pattern: &str) {
- // need to borrow via pattern match otherwise it complains about simultaneous borrow
- let Self {
- ref mut matcher,
- ref mut matches,
- ref options,
- ..
- } = *self;
-
// reuse the matches allocation
- matches.clear();
- matches.extend(options.iter().enumerate().filter_map(|(index, option)| {
- let text = option.filter_text();
- // TODO: using fuzzy_indices could give us the char idx for match highlighting
- matcher
- .fuzzy_match(text, pattern)
- .map(|score| (index, score))
- }));
+ self.matches.clear();
+ self.matches.extend(
+ self.options
+ .iter()
+ .enumerate()
+ .filter_map(|(index, option)| {
+ let text = option.filter_text();
+ // TODO: using fuzzy_indices could give us the char idx for match highlighting
+ self.matcher
+ .fuzzy_match(text, pattern)
+ .map(|score| (index, score))
+ }),
+ );
// matches.sort_unstable_by_key(|(_, score)| -score);
- matches.sort_unstable_by_key(|(index, _score)| options[*index].sort_text());
+ self.matches
+ .sort_unstable_by_key(|(index, _score)| self.options[*index].sort_text());
// reset cursor position
self.cursor = None;