@@ -234,6 +234,84 @@ impl<T: Item + 'static> FilePicker<T> {
234 .collect();
234 .collect();
237+ pub fn score(&mut self) {
238+ let pattern = self.prompt.line();
240+ if pattern == &self.previous_pattern.0 {
244+ let (query, is_refined) = self
247+ .refine(pattern, &self.previous_pattern.0);
249+ if pattern.is_empty() {
250+ // Fast path for no pattern.
251+ self.matches.clear();
253+ .extend(self.options.iter().enumerate().map(|(index, option)| {
254+ let text = option.filter_text(&self.editor_data);
258+ len: text.chars().count(),
261+ } else if is_refined {
262+ // optimization: if the pattern is a more specific version of the previous one
263+ // then we can score the filtered set.
264+ self.matches.retain_mut(|pmatch| {
265+ let option = &self.options[pmatch.index];
266+ let text = option.sort_text(&self.editor_data);
268+ match query.fuzzy_match(&text, &self.matcher) {
278+ self.matches.sort_unstable();
283+ // reset cursor position
285+ let pattern = self.prompt.line();
286+ self.previous_pattern.0.clone_from(pattern);
287+ self.previous_pattern.1 = query;
290+ pub fn force_score(&mut self) {
291+ let pattern = self.prompt.line();
293+ let query = FuzzyQuery::new(pattern);
294+ self.matches.clear();
295+ self.matches.extend(
299+ .filter_map(|(index, option)| {
300+ let text = option.filter_text(&self.editor_data);
303+ .fuzzy_match(&text, &self.matcher)
304+ .map(|score| PickerMatch {
307+ len: text.chars().count(),
312+ self.matches.sort_unstable();
237 fn current_file(&self, editor: &Editor) -> Option<FileLocation> {
315 fn current_file(&self, editor: &Editor) -> Option<FileLocation> {
238 self.picker
316 self.picker
239 .selection()
317 .selection()
@@ -569,81 +647,11 @@ impl<T: Item> Picker<T> {
571 pub fn score(&mut self) {
649 pub fn score(&mut self) {
572− let pattern = self.prompt.line();
650+ unimplemented!()
574− if pattern == &self.previous_pattern.0 {
578− let (query, is_refined) = self
581− .refine(pattern, &self.previous_pattern.0);
583− if pattern.is_empty() {
584− // Fast path for no pattern.
585− self.matches.clear();
587− .extend(self.options.iter().enumerate().map(|(index, option)| {
588− let text = option.filter_text(&self.editor_data);
592− len: text.chars().count(),
595− } else if is_refined {
596− // optimization: if the pattern is a more specific version of the previous one
597− // then we can score the filtered set.
598− self.matches.retain_mut(|pmatch| {
599− let option = &self.options[pmatch.index];
600− let text = option.sort_text(&self.editor_data);
602− match query.fuzzy_match(&text, &self.matcher) {
612− self.matches.sort_unstable();
617− // reset cursor position
619− let pattern = self.prompt.line();
620− self.previous_pattern.0.clone_from(pattern);
621− self.previous_pattern.1 = query;
624 pub fn force_score(&mut self) {
653 pub fn force_score(&mut self) {
625− let pattern = self.prompt.line();
654+ unimplemented!()
627− let query = FuzzyQuery::new(pattern);
628− self.matches.clear();
629− self.matches.extend(
633− .filter_map(|(index, option)| {
634− let text = option.filter_text(&self.editor_data);
637− .fuzzy_match(&text, &self.matcher)
638− .map(|score| PickerMatch {
641− len: text.chars().count(),
646− self.matches.sort_unstable();
649 /// Move the cursor by a number of lines, either down (`Forward`) or up (`Backward`)
657 /// Move the cursor by a number of lines, either down (`Forward`) or up (`Backward`)