language: Assert CodeLabel text ranges are correct (#40242)
Release Notes: - N/A *or* Added/Fixed/Improved ...
This commit is contained in:
@@ -407,11 +407,6 @@ impl LspAdapter for PyrightLspAdapter {
|
||||
return None;
|
||||
}
|
||||
};
|
||||
let filter_range = item
|
||||
.filter_text
|
||||
.as_deref()
|
||||
.and_then(|filter| label.find(filter).map(|ix| ix..ix + filter.len()))
|
||||
.unwrap_or(0..label.len());
|
||||
let mut text = label.clone();
|
||||
if let Some(completion_details) = item
|
||||
.label_details
|
||||
@@ -420,14 +415,14 @@ impl LspAdapter for PyrightLspAdapter {
|
||||
{
|
||||
write!(&mut text, " {}", completion_details).ok();
|
||||
}
|
||||
Some(language::CodeLabel {
|
||||
runs: highlight_id
|
||||
Some(language::CodeLabel::filtered(
|
||||
text,
|
||||
item.filter_text.as_deref(),
|
||||
highlight_id
|
||||
.map(|id| (0..label.len(), id))
|
||||
.into_iter()
|
||||
.collect(),
|
||||
text,
|
||||
filter_range,
|
||||
})
|
||||
))
|
||||
}
|
||||
|
||||
async fn label_for_symbol(
|
||||
@@ -458,11 +453,11 @@ impl LspAdapter for PyrightLspAdapter {
|
||||
_ => return None,
|
||||
};
|
||||
|
||||
Some(language::CodeLabel {
|
||||
runs: language.highlight_text(&text.as_str().into(), display_range.clone()),
|
||||
text: text[display_range].to_string(),
|
||||
Some(language::CodeLabel::new(
|
||||
text[display_range.clone()].to_string(),
|
||||
filter_range,
|
||||
})
|
||||
language.highlight_text(&text.as_str().into(), display_range),
|
||||
))
|
||||
}
|
||||
|
||||
async fn workspace_configuration(
|
||||
@@ -1424,16 +1419,11 @@ impl LspAdapter for PyLspAdapter {
|
||||
lsp::CompletionItemKind::CONSTANT => grammar.highlight_id_for_name("constant")?,
|
||||
_ => return None,
|
||||
};
|
||||
let filter_range = item
|
||||
.filter_text
|
||||
.as_deref()
|
||||
.and_then(|filter| label.find(filter).map(|ix| ix..ix + filter.len()))
|
||||
.unwrap_or(0..label.len());
|
||||
Some(language::CodeLabel {
|
||||
text: label.clone(),
|
||||
runs: vec![(0..label.len(), highlight_id)],
|
||||
filter_range,
|
||||
})
|
||||
Some(language::CodeLabel::filtered(
|
||||
label.clone(),
|
||||
item.filter_text.as_deref(),
|
||||
vec![(0..label.len(), highlight_id)],
|
||||
))
|
||||
}
|
||||
|
||||
async fn label_for_symbol(
|
||||
@@ -1463,12 +1453,11 @@ impl LspAdapter for PyLspAdapter {
|
||||
}
|
||||
_ => return None,
|
||||
};
|
||||
|
||||
Some(language::CodeLabel {
|
||||
runs: language.highlight_text(&text.as_str().into(), display_range.clone()),
|
||||
text: text[display_range].to_string(),
|
||||
Some(language::CodeLabel::new(
|
||||
text[display_range.clone()].to_string(),
|
||||
filter_range,
|
||||
})
|
||||
language.highlight_text(&text.as_str().into(), display_range),
|
||||
))
|
||||
}
|
||||
|
||||
async fn workspace_configuration(
|
||||
@@ -1708,11 +1697,6 @@ impl LspAdapter for BasedPyrightLspAdapter {
|
||||
return None;
|
||||
}
|
||||
};
|
||||
let filter_range = item
|
||||
.filter_text
|
||||
.as_deref()
|
||||
.and_then(|filter| label.find(filter).map(|ix| ix..ix + filter.len()))
|
||||
.unwrap_or(0..label.len());
|
||||
let mut text = label.clone();
|
||||
if let Some(completion_details) = item
|
||||
.label_details
|
||||
@@ -1721,14 +1705,14 @@ impl LspAdapter for BasedPyrightLspAdapter {
|
||||
{
|
||||
write!(&mut text, " {}", completion_details).ok();
|
||||
}
|
||||
Some(language::CodeLabel {
|
||||
runs: highlight_id
|
||||
Some(language::CodeLabel::filtered(
|
||||
text,
|
||||
item.filter_text.as_deref(),
|
||||
highlight_id
|
||||
.map(|id| (0..label.len(), id))
|
||||
.into_iter()
|
||||
.collect(),
|
||||
text,
|
||||
filter_range,
|
||||
})
|
||||
))
|
||||
}
|
||||
|
||||
async fn label_for_symbol(
|
||||
@@ -1758,12 +1742,11 @@ impl LspAdapter for BasedPyrightLspAdapter {
|
||||
}
|
||||
_ => return None,
|
||||
};
|
||||
|
||||
Some(language::CodeLabel {
|
||||
runs: language.highlight_text(&text.as_str().into(), display_range.clone()),
|
||||
text: text[display_range].to_string(),
|
||||
Some(language::CodeLabel::new(
|
||||
text[display_range.clone()].to_string(),
|
||||
filter_range,
|
||||
})
|
||||
language.highlight_text(&text.as_str().into(), display_range),
|
||||
))
|
||||
}
|
||||
|
||||
async fn workspace_configuration(
|
||||
|
||||
Reference in New Issue
Block a user