on master help sign in
Don't use word splitting during fuzzy matching (#8192)
commite6cdc5f9d327d30886a8fa2961e7a55b4ca0b692 authorPascal Kuthe <pascal.kuthe@semimod.de> dateWed 6 Sep 2023, 16:03 (3 years ago) parent0cfd46c
2 files changed+6−6
helix-core/src/fuzzy.rs+3−3 helix-term/src/ui/menu.rs+3−3
helix-core/src/fuzzy.rs+3−3
@@ -1,6 +1,6 @@
11use std::ops::DerefMut;
22
3−use nucleo::pattern::{AtomKind, CaseMatching, Pattern};
3+use nucleo::pattern::{Atom, AtomKind, CaseMatching};
44use nucleo::Config;
55use parking_lot::Mutex;
66
@@ -32,12 +32,12 @@ pub fn fuzzy_match<T: AsRef<str>>(
3232 pattern: &str,
3333 items: impl IntoIterator<Item = T>,
3434 path: bool,
35−) -> Vec<(T, u32)> {
35+) -> Vec<(T, u16)> {
3636 let mut matcher = MATCHER.lock();
3737 matcher.config = Config::DEFAULT;
3838 if path {
3939 matcher.config.set_match_paths();
4040 }
41− let pattern = Pattern::new(pattern, CaseMatching::Smart, AtomKind::Fuzzy);
41+ let pattern = Atom::new(pattern, CaseMatching::Smart, AtomKind::Fuzzy, false);
4242 pattern.match_list(items, &mut matcher)
4343}
helix-term/src/ui/menu.rs+3−3
@@ -5,7 +5,7 @@ use crate::{
55 ctrl, key, shift,
66};
77use helix_core::fuzzy::MATCHER;
8−use nucleo::pattern::{AtomKind, CaseMatching, Pattern};
8+use nucleo::pattern::{Atom, AtomKind, CaseMatching};
99use nucleo::{Config, Utf32Str};
1010use tui::{buffer::Buffer as Surface, widgets::Table};
1111
@@ -94,13 +94,13 @@ impl<T: Item> Menu<T> {
9494 self.matches.clear();
9595 let mut matcher = MATCHER.lock();
9696 matcher.config = Config::DEFAULT;
97− let pattern = Pattern::new(pattern, CaseMatching::Ignore, AtomKind::Fuzzy);
97+ let pattern = Atom::new(pattern, CaseMatching::Ignore, AtomKind::Fuzzy, false);
9898 let mut buf = Vec::new();
9999 let matches = self.options.iter().enumerate().filter_map(|(i, option)| {
100100 let text = option.filter_text(&self.editor_data);
101101 pattern
102102 .score(Utf32Str::new(&text, &mut buf), &mut matcher)
103− .map(|score| (i as u32, score))
103+ .map(|score| (i as u32, score as u32))
104104 });
105105 self.matches.extend(matches);
106106 self.matches