Compare commits

...

1 Commits

Author SHA1 Message Date
Dmitriy Kovalenko edb84dd0f1 feat: Improve scoring for matching casing
Now it completely ignores casing if the query doesn't contain at least
one upper case character and scores much better if you have the exact
matching case character with a haystack.
2025-09-26 17:05:44 -07:00
3 changed files with 6 additions and 5 deletions
Generated
+2 -2
View File
@@ -805,9 +805,9 @@ dependencies = [
[[package]]
name = "neo_frizbee"
version = "0.7.0"
version = "0.7.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "021c5b347f5d2a54823afe6bd29b5079d53e9eb50c1ee38a7dab82e6ea07c8f8"
checksum = "2b4421f748f561dd0bb677e46f2e6c1ed2c52ba7130349229a73445af5010d17"
dependencies = [
"multiversion",
"rayon",
+1 -1
View File
@@ -26,7 +26,7 @@ ignore = "0.4.22"
mimalloc = "0.1.47"
mlua = { version = "0.11.1", features = ["module", "luajit"] }
neo_frizbee = { version = "0.7.0" }
neo_frizbee = { version = "0.7.1" }
notify = "8.1.0"
notify-debouncer-mini = "0.7"
once_cell = "1.20.2"
+3 -2
View File
@@ -27,12 +27,13 @@ pub fn match_and_score_files<'a>(
sort: false,
scoring: Scoring {
capitalization_bonus: if has_uppercase_letter { 8 } else { 0 },
matching_case_bonus: if has_uppercase_letter { 4 } else { 0 },
..Default::default()
},
};
let query_contains_path_separator = context.query.contains(MAIN_SEPARATOR);
let haystack: Vec<&str> = files.iter().map(|f| f.relative_path.as_str()).collect();
let haystack: Vec<_> = files.iter().map(|f| f.relative_path.to_lowercase()).collect();
tracing::debug!(
"Starting fuzzy search for query '{}' in {} files",
context.query,
@@ -50,7 +51,7 @@ pub fn match_and_score_files<'a>(
// instead of spawning a separate matching process, but it's okay for the beta
let haystack_of_filenames = path_matches
.par_iter()
.filter_map(|m| files.get(m.index as usize).map(|f| f.file_name.as_str()))
.filter_map(|m| files.get(m.index as usize).map(|f| f.file_name.to_lowercase()))
.collect::<Vec<_>>();
// if there is a / in the query we don't even match filenames