From 10db35d897d248652ff9f6872b7221708e29f86d Mon Sep 17 00:00:00 2001 From: Pascal Kuthe Date: Wed, 6 Sep 2023 13:38:57 +0200 Subject: [PATCH] Don't use word splitting during fuzzy matching --- helix-core/src/fuzzy.rs | 6 +++--- helix-term/src/ui/menu.rs | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/helix-core/src/fuzzy.rs b/helix-core/src/fuzzy.rs index e40a2d06e3a3..549c6b0e54b6 100644 --- a/helix-core/src/fuzzy.rs +++ b/helix-core/src/fuzzy.rs @@ -1,6 +1,6 @@ use std::ops::DerefMut; -use nucleo::pattern::{AtomKind, CaseMatching, Pattern}; +use nucleo::pattern::{Atom, AtomKind, CaseMatching}; use nucleo::Config; use parking_lot::Mutex; @@ -32,12 +32,12 @@ pub fn fuzzy_match>( pattern: &str, items: impl IntoIterator, path: bool, -) -> Vec<(T, u32)> { +) -> Vec<(T, u16)> { let mut matcher = MATCHER.lock(); matcher.config = Config::DEFAULT; if path { matcher.config.set_match_paths(); } - let pattern = Pattern::new(pattern, CaseMatching::Smart, AtomKind::Fuzzy); + let pattern = Atom::new(pattern, CaseMatching::Smart, AtomKind::Fuzzy, false); pattern.match_list(items, &mut matcher) } diff --git a/helix-term/src/ui/menu.rs b/helix-term/src/ui/menu.rs index 8eeb41eea13e..9704b1f2ab94 100644 --- a/helix-term/src/ui/menu.rs +++ b/helix-term/src/ui/menu.rs @@ -5,7 +5,7 @@ use crate::{ ctrl, key, shift, }; use helix_core::fuzzy::MATCHER; -use nucleo::pattern::{AtomKind, CaseMatching, Pattern}; +use nucleo::pattern::{Atom, AtomKind, CaseMatching}; use nucleo::{Config, Utf32Str}; use tui::{buffer::Buffer as Surface, widgets::Table}; @@ -94,13 +94,13 @@ impl Menu { self.matches.clear(); let mut matcher = MATCHER.lock(); matcher.config = Config::DEFAULT; - let pattern = Pattern::new(pattern, CaseMatching::Ignore, AtomKind::Fuzzy); + let pattern = Atom::new(pattern, CaseMatching::Ignore, AtomKind::Fuzzy, false); let mut buf = Vec::new(); let matches = self.options.iter().enumerate().filter_map(|(i, option)| { let text = option.filter_text(&self.editor_data); pattern .score(Utf32Str::new(&text, &mut buf), &mut matcher) - .map(|score| (i as u32, score)) + .map(|score| (i as u32, score as u32)) }); self.matches.extend(matches); self.matches