language: Fix completion menu no longer prioritizes relevant items for Typescript and Python (#42065)

Closes #41672

Regressed in https://github.com/zed-industries/zed/pull/40242

Release Notes:

- Fixed issue where completion menu no longer prioritizes relevant items
for TypeScript and Python.
This commit is contained in:
Smit Barmase
2025-11-06 13:19:46 +05:30
committed by GitHub
parent 2b6cf31ace
commit 92cfce568b
4 changed files with 17 additions and 7 deletions
+4 -2
View File
@@ -2324,17 +2324,19 @@ impl CodeLabel {
}
pub fn plain(text: String, filter_text: Option<&str>) -> Self {
Self::filtered(text, filter_text, Vec::new())
Self::filtered(text.clone(), text.len(), filter_text, Vec::new())
}
pub fn filtered(
text: String,
label_len: usize,
filter_text: Option<&str>,
runs: Vec<(Range<usize>, HighlightId)>,
) -> Self {
assert!(label_len <= text.len());
let filter_range = filter_text
.and_then(|filter| text.find(filter).map(|ix| ix..ix + filter.len()))
.unwrap_or(0..text.len());
.unwrap_or(0..label_len);
Self::new(text, filter_range, runs)
}