Skip to content

Commit

Permalink
Bump nucleo to v0.4.0
Browse files Browse the repository at this point in the history
We will use this in the child commit to improve the picker's running
indicator. Nucleo 0.4.0 includes an `active_injectors` member that we
can use to detect if anything can push to the picker. When that count
drops to zero we can remove the running indicator.
  • Loading branch information
the-mikedavis committed Feb 25, 2024
1 parent 1fba47d commit ea2ff77
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 20 deletions.
15 changes: 4 additions & 11 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ package.helix-term.opt-level = 2

[workspace.dependencies]
tree-sitter = { version = "0.20", git = "https://github.com/helix-editor/tree-sitter", rev = "660481dbf71413eba5a928b0b0ab8da50c1109e0" }
nucleo = "0.2.0"
nucleo = "0.4.0"

[workspace.package]
version = "23.10.0"
Expand Down
10 changes: 8 additions & 2 deletions helix-core/src/fuzzy.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use std::ops::DerefMut;

use nucleo::pattern::{Atom, AtomKind, CaseMatching};
use nucleo::pattern::{Atom, AtomKind, CaseMatching, Normalization};
use nucleo::Config;
use parking_lot::Mutex;

Expand Down Expand Up @@ -38,6 +38,12 @@ pub fn fuzzy_match<T: AsRef<str>>(
if path {
matcher.config.set_match_paths();
}
let pattern = Atom::new(pattern, CaseMatching::Smart, AtomKind::Fuzzy, false);
let pattern = Atom::new(
pattern,
CaseMatching::Smart,
Normalization::Smart,
AtomKind::Fuzzy,
false,
);
pattern.match_list(items, &mut matcher)
}
10 changes: 8 additions & 2 deletions helix-term/src/ui/menu.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use crate::{
ctrl, key, shift,
};
use helix_core::fuzzy::MATCHER;
use nucleo::pattern::{Atom, AtomKind, CaseMatching};
use nucleo::pattern::{Atom, AtomKind, CaseMatching, Normalization};
use nucleo::{Config, Utf32Str};
use tui::{
buffer::Buffer as Surface,
Expand Down Expand Up @@ -87,7 +87,13 @@ impl<T: Item> Menu<T> {
pub fn score(&mut self, pattern: &str, incremental: bool) {
let mut matcher = MATCHER.lock();
matcher.config = Config::DEFAULT;
let pattern = Atom::new(pattern, CaseMatching::Ignore, AtomKind::Fuzzy, false);
let pattern = Atom::new(
pattern,
CaseMatching::Ignore,
Normalization::Smart,
AtomKind::Fuzzy,
false,
);
let mut buf = Vec::new();
if incremental {
self.matches.retain_mut(|(index, score)| {
Expand Down
12 changes: 8 additions & 4 deletions helix-term/src/ui/picker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ use crate::{
};
use futures_util::future::BoxFuture;
use helix_event::AsyncHook;
use nucleo::pattern::CaseMatching;
use nucleo::pattern::{CaseMatching, Normalization};
use nucleo::{Config, Nucleo, Utf32String};
use tui::{
buffer::Buffer as Surface,
Expand Down Expand Up @@ -494,9 +494,13 @@ impl<T: 'static + Send + Sync, D: 'static + Send + Sync> Picker<T, D> {
})
.unwrap_or(false);

self.matcher
.pattern
.reparse(i, pattern, CaseMatching::Smart, append);
self.matcher.pattern.reparse(
i,
pattern,
CaseMatching::Smart,
Normalization::Smart,
append,
);
}
self.query = new_query;
}
Expand Down

0 comments on commit ea2ff77

Please sign in to comment.