@@ -10,6 +10,8 @@ use tui::{
1010use fuzzy_matcher::skim::SkimMatcherV2 as Matcher;
1111use fuzzy_matcher::FuzzyMatcher;
1212
13+use std::borrow::Cow;
14+
1315use crate::ui::{Prompt, PromptEvent};
1416use helix_core::Position;
1517use helix_view::Editor;
@@ -25,14 +27,14 @@ pub struct Picker<T> {
2527 // pattern: String,
2628 prompt: Prompt,
2729
28− format_fn: Box<dyn Fn(&T) -> &str>,
30+ format_fn: Box<dyn Fn(&T) -> Cow<str>>,
2931 callback_fn: Box<dyn Fn(&mut Editor, &T)>,
3032}
3133
3234impl<T> Picker<T> {
3335 pub fn new(
3436 options: Vec<T>,
35− format_fn: impl Fn(&T) -> &str + 'static,
37+ format_fn: impl Fn(&T) -> Cow<str> + 'static,
3638 callback_fn: impl Fn(&mut Editor, &T) + 'static,
3739 ) -> Self {
3840 let prompt = Prompt::new(
@@ -82,7 +84,7 @@ impl<T> Picker<T> {
8284 let text = (format_fn)(option);
8385 // TODO: using fuzzy_indices could give us the char idx for match highlighting
8486 matcher
85− .fuzzy_match(text, pattern)
87+ .fuzzy_match(&text, pattern)
8688 .map(|score| (index, score))
8789 }),
8890 );