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
+7 -1
View File
@@ -406,6 +406,7 @@ impl LspAdapter for PyrightLspAdapter {
language: &Arc<language::Language>,
) -> Option<language::CodeLabel> {
let label = &item.label;
let label_len = label.len();
let grammar = language.grammar()?;
let highlight_id = match item.kind? {
lsp::CompletionItemKind::METHOD => grammar.highlight_id_for_name("function.method"),
@@ -427,9 +428,10 @@ impl LspAdapter for PyrightLspAdapter {
}
Some(language::CodeLabel::filtered(
text,
label_len,
item.filter_text.as_deref(),
highlight_id
.map(|id| (0..label.len(), id))
.map(|id| (0..label_len, id))
.into_iter()
.collect(),
))
@@ -1467,6 +1469,7 @@ impl LspAdapter for PyLspAdapter {
language: &Arc<language::Language>,
) -> Option<language::CodeLabel> {
let label = &item.label;
let label_len = label.len();
let grammar = language.grammar()?;
let highlight_id = match item.kind? {
lsp::CompletionItemKind::METHOD => grammar.highlight_id_for_name("function.method")?,
@@ -1477,6 +1480,7 @@ impl LspAdapter for PyLspAdapter {
};
Some(language::CodeLabel::filtered(
label.clone(),
label_len,
item.filter_text.as_deref(),
vec![(0..label.len(), highlight_id)],
))
@@ -1742,6 +1746,7 @@ impl LspAdapter for BasedPyrightLspAdapter {
language: &Arc<language::Language>,
) -> Option<language::CodeLabel> {
let label = &item.label;
let label_len = label.len();
let grammar = language.grammar()?;
let highlight_id = match item.kind? {
lsp::CompletionItemKind::METHOD => grammar.highlight_id_for_name("function.method"),
@@ -1763,6 +1768,7 @@ impl LspAdapter for BasedPyrightLspAdapter {
}
Some(language::CodeLabel::filtered(
text,
label_len,
item.filter_text.as_deref(),
highlight_id
.map(|id| (0..label.len(), id))