@@ -10,6 +10,8 @@ use tui::{
10use fuzzy_matcher::skim::SkimMatcherV2 as Matcher;
10use fuzzy_matcher::skim::SkimMatcherV2 as Matcher;
11use fuzzy_matcher::FuzzyMatcher;
11use fuzzy_matcher::FuzzyMatcher;
13use crate::ui::{Prompt, PromptEvent};
15use crate::ui::{Prompt, PromptEvent};
14use helix_core::Position;
16use helix_core::Position;
15use helix_view::Editor;
17use helix_view::Editor;
@@ -25,14 +27,14 @@ pub struct Picker<T> {
25 // pattern: String,
27 // pattern: String,
26 prompt: Prompt,
28 prompt: Prompt,
28− format_fn: Box<dyn Fn(&T) -> &str>,
30+ format_fn: Box<dyn Fn(&T) -> Cow<str>>,
29 callback_fn: Box<dyn Fn(&mut Editor, &T)>,
31 callback_fn: Box<dyn Fn(&mut Editor, &T)>,
32impl<T> Picker<T> {
34impl<T> Picker<T> {
33 pub fn new(
35 pub fn new(
34 options: Vec<T>,
36 options: Vec<T>,
35− format_fn: impl Fn(&T) -> &str + 'static,
37+ format_fn: impl Fn(&T) -> Cow<str> + 'static,
36 callback_fn: impl Fn(&mut Editor, &T) + 'static,
38 callback_fn: impl Fn(&mut Editor, &T) + 'static,
37 ) -> Self {
39 ) -> Self {
38 let prompt = Prompt::new(
40 let prompt = Prompt::new(
@@ -82,7 +84,7 @@ impl<T> Picker<T> {
82 let text = (format_fn)(option);
84 let text = (format_fn)(option);
83 // TODO: using fuzzy_indices could give us the char idx for match highlighting
85 // TODO: using fuzzy_indices could give us the char idx for match highlighting
85− .fuzzy_match(text, pattern)
87+ .fuzzy_match(&text, pattern)
86 .map(|score| (index, score))
88 .map(|score| (index, score))