file_finder: Fix filename matching to require contiguous characters (#28093)

Improves https://github.com/zed-industries/zed/pull/27937 to only
prioritize file name if it's contiguous character match.

Release Notes:

- N/A

Co-authored-by: Conrad Irwin <conrad.irwin@gmail.com>
This commit is contained in:
Smit Barmase
2025-04-05 05:01:56 +05:30
committed by GitHub
co-authored by Conrad Irwin
parent 03aadb4e5b
commit 10821aae2c
+10 -1
View File
@@ -581,7 +581,16 @@ impl Matches {
let filename_str = filename.to_string_lossy();
if let Some(filename_pos) = path_str.rfind(&*filename_str) {
return panel_match.0.positions[0] >= filename_pos;
if panel_match.0.positions[0] >= filename_pos {
let mut prev_position = panel_match.0.positions[0];
for p in &panel_match.0.positions[1..] {
if *p != prev_position + 1 {
return false;
}
prev_position = *p;
}
return true;
}
}
}