fix sort order of literal matcher (#13)

This commit is contained in:
Pascal Kuthe 2023-08-21 01:02:53 +02:00 committed by GitHub
parent 685e699bc5
commit f18c19cd53
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 5 additions and 3 deletions

View File

@ -2,7 +2,7 @@
name = "nucleo"
description = "plug and play high performance fuzzy matcher"
authors = ["Pascal Kuthe <pascal.kuthe@semimod.de>"]
version = "0.1.0"
version = "0.1.1"
edition = "2021"
license = "MPL-2.0"
repository = "https://github.com/helix-editor/nucleo"

View File

@ -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
}

View File

@ -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 {