From 4a382b27977e9d7dbc349553d045aa50f0635834 Mon Sep 17 00:00:00 2001 From: Nereuxofficial <37740907+Nereuxofficial@users.noreply.github.com> Date: Mon, 8 Dec 2025 19:50:20 +0100 Subject: [PATCH] fuzzy: Use lowercase representations for matrix size calculation (#44338) Closes #44324 Release Notes: - Uses the lowercase representation of the query for the matrix length calculation to match the bounds size expected in `recursive_score_match` --- crates/fuzzy/src/matcher.rs | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/crates/fuzzy/src/matcher.rs b/crates/fuzzy/src/matcher.rs index eb844e349821394785bb61a34600f04a6fa985eb..782c9caca832d81fb6e4bce8f49b4f310664b292 100644 --- a/crates/fuzzy/src/matcher.rs +++ b/crates/fuzzy/src/matcher.rs @@ -96,7 +96,8 @@ impl<'a> Matcher<'a> { continue; } - let matrix_len = self.query.len() * (prefix.len() + candidate_chars.len()); + let matrix_len = + self.query.len() * (lowercase_prefix.len() + lowercase_candidate_chars.len()); self.score_matrix.clear(); self.score_matrix.resize(matrix_len, None); self.best_position_matrix.clear(); @@ -596,4 +597,15 @@ mod tests { }) .collect() } + + /// Test for https://github.com/zed-industries/zed/issues/44324 + #[test] + fn test_recursive_score_match_index_out_of_bounds() { + let paths = vec!["İ/İ/İ/İ"]; + let query = "İ/İ"; + + // This panicked with "index out of bounds: the len is 21 but the index is 22" + let result = match_single_path_query(query, false, &paths); + let _ = result; + } }