@@ -1,7 +1,7 @@
11use crate::{
22 compositor::{Component, Compositor, Context, Event, EventResult},
33 ctrl, key, shift,
4− ui::{self, EditorView},
4+ ui::{self, fuzzy_match::FuzzyQuery, EditorView},
55};
66use tui::{
77 buffer::Buffer as Surface,
@@ -9,7 +9,6 @@ use tui::{
99};
1010
1111use fuzzy_matcher::skim::SkimMatcherV2 as Matcher;
12−use fuzzy_matcher::FuzzyMatcher;
1312use tui::widgets::Widget;
1413
1514use std::time::Instant;
@@ -389,13 +388,14 @@ impl<T: Item> Picker<T> {
389388 .map(|(index, _option)| (index, 0)),
390389 );
391390 } else if pattern.starts_with(&self.previous_pattern) {
391+ let query = FuzzyQuery::new(pattern);
392392 // optimization: if the pattern is a more specific version of the previous one
393393 // then we can score the filtered set.
394394 self.matches.retain_mut(|(index, score)| {
395395 let option = &self.options[*index];
396396 let text = option.sort_text(&self.editor_data);
397397
398− match self.matcher.fuzzy_match(&text, pattern) {
398+ match query.fuzzy_match(&text, &self.matcher) {
399399 Some(s) => {
400400 // Update the score
401401 *score = s;
@@ -408,6 +408,7 @@ impl<T: Item> Picker<T> {
408408 self.matches
409409 .sort_unstable_by_key(|(_, score)| Reverse(*score));
410410 } else {
411+ let query = FuzzyQuery::new(pattern);
411412 self.matches.clear();
412413 self.matches.extend(
413414 self.options
@@ -423,8 +424,8 @@ impl<T: Item> Picker<T> {
423424
424425 let text = option.filter_text(&self.editor_data);
425426
426− self.matcher
427− .fuzzy_match(&text, pattern)
427+ query
428+ .fuzzy_match(&text, &self.matcher)
428429 .map(|score| (index, score))
429430 }),
430431 );
@@ -657,9 +658,8 @@ impl<T: Item + 'static> Component for Picker<T> {
657658 }
658659
659660 let spans = option.label(&self.editor_data);
660− let (_score, highlights) = self
661− .matcher
662− .fuzzy_indices(&String::from(&spans), self.prompt.line())
661+ let (_score, highlights) = FuzzyQuery::new(self.prompt.line())
662+ .fuzzy_indicies(&String::from(&spans), &self.matcher)
663663 .unwrap_or_default();
664664
665665 spans.0.into_iter().fold(inner, |pos, span| {