Skip to content

Commit

Permalink
fix sort order of literal matcher (helix-editor#13)
Browse files Browse the repository at this point in the history
  • Loading branch information
pascalkuthe committed Aug 20, 2023
1 parent 685e699 commit f18c19c
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 3 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
name = "nucleo"
description = "plug and play high performance fuzzy matcher"
authors = ["Pascal Kuthe <[email protected]>"]
version = "0.1.0"
version = "0.1.1"
edition = "2021"
license = "MPL-2.0"
repository = "https://github.com/helix-editor/nucleo"
Expand Down
2 changes: 1 addition & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -345,6 +345,6 @@ pub fn fuzzy_match<T: AsRef<str>>(
.map(|score| (item, score))
})
.collect();
items.sort_by_key(|(item, score)| (Reverse(*score), item.as_ref().len()));
items.sort_by_key(|(_, score)| Reverse(*score));
items
}
4 changes: 3 additions & 1 deletion src/pattern.rs
Original file line number Diff line number Diff line change
Expand Up @@ -373,7 +373,9 @@ impl Pattern {
self.atoms.clear();
let pattern =
PatternAtom::literal(pattern, self.normalize, self.case_matching, kind, false);
self.atoms.push(pattern);
if !pattern.needle.is_empty() {
self.atoms.push(pattern);
}
self.status = if append && self.status != Status::Rescore {
Status::Update
} else {
Expand Down

0 comments on commit f18c19c

Please sign in to comment.