@@ -1,7 +1,7 @@
1use crate::{
1use crate::{
2 compositor::{Component, Compositor, Context, Event, EventResult},
2 compositor::{Component, Compositor, Context, Event, EventResult},
3 ctrl, key, shift,
3 ctrl, key, shift,
4− ui::{self, EditorView},
4+ ui::{self, fuzzy_match::FuzzyQuery, EditorView},
7 buffer::Buffer as Surface,
7 buffer::Buffer as Surface,
@@ -9,7 +9,6 @@ use tui::{
11use fuzzy_matcher::skim::SkimMatcherV2 as Matcher;
11use fuzzy_matcher::skim::SkimMatcherV2 as Matcher;
12−use fuzzy_matcher::FuzzyMatcher;
13use tui::widgets::Widget;
12use tui::widgets::Widget;
15use std::time::Instant;
14use std::time::Instant;
@@ -389,13 +388,14 @@ impl<T: Item> Picker<T> {
389 .map(|(index, _option)| (index, 0)),
388 .map(|(index, _option)| (index, 0)),
391 } else if pattern.starts_with(&self.previous_pattern) {
390 } else if pattern.starts_with(&self.previous_pattern) {
391+ let query = FuzzyQuery::new(pattern);
392 // optimization: if the pattern is a more specific version of the previous one
392 // optimization: if the pattern is a more specific version of the previous one
393 // then we can score the filtered set.
393 // then we can score the filtered set.
394 self.matches.retain_mut(|(index, score)| {
394 self.matches.retain_mut(|(index, score)| {
395 let option = &self.options[*index];
395 let option = &self.options[*index];
396 let text = option.sort_text(&self.editor_data);
396 let text = option.sort_text(&self.editor_data);
398− match self.matcher.fuzzy_match(&text, pattern) {
398+ match query.fuzzy_match(&text, &self.matcher) {
399 Some(s) => {
399 Some(s) => {
400 // Update the score
400 // Update the score
401 *score = s;
401 *score = s;
@@ -408,6 +408,7 @@ impl<T: Item> Picker<T> {
408 self.matches
408 self.matches
409 .sort_unstable_by_key(|(_, score)| Reverse(*score));
409 .sort_unstable_by_key(|(_, score)| Reverse(*score));
411+ let query = FuzzyQuery::new(pattern);
411 self.matches.clear();
412 self.matches.clear();
412 self.matches.extend(
413 self.matches.extend(
413 self.options
414 self.options
@@ -423,8 +424,8 @@ impl<T: Item> Picker<T> {
424 let text = option.filter_text(&self.editor_data);
425 let text = option.filter_text(&self.editor_data);
426− self.matcher
427+ query
427− .fuzzy_match(&text, pattern)
428+ .fuzzy_match(&text, &self.matcher)
428 .map(|score| (index, score))
429 .map(|score| (index, score))
@@ -657,9 +658,8 @@ impl<T: Item + 'static> Component for Picker<T> {
659 let spans = option.label(&self.editor_data);
660 let spans = option.label(&self.editor_data);
660− let (_score, highlights) = self
661+ let (_score, highlights) = FuzzyQuery::new(self.prompt.line())
662− .fuzzy_indices(&String::from(&spans), self.prompt.line())
662+ .fuzzy_indicies(&String::from(&spans), &self.matcher)
663 .unwrap_or_default();
663 .unwrap_or_default();
665 spans.0.into_iter().fold(inner, |pos, span| {
665 spans.0.into_iter().fold(inner, |pos, span| {