mirror of
https://github.com/zed-industries/zed.git
synced 2024-09-19 18:41:56 +03:00
Don't generate invalid ranges for C code (#13183)
Fixes: #13128 Release Notes: - Fixed a panic when editing C code ([#13128](https://github.com/zed-industries/zed/issues/13128)).
This commit is contained in:
parent
7003b0f211
commit
0af6e442a7
@ -197,8 +197,16 @@ impl super::LspAdapter for CLspAdapter {
|
|||||||
let detail = completion.detail.as_ref().unwrap();
|
let detail = completion.detail.as_ref().unwrap();
|
||||||
let text = format!("{} {}", detail, label);
|
let text = format!("{} {}", detail, label);
|
||||||
let runs = language.highlight_text(&Rope::from(text.as_str()), 0..text.len());
|
let runs = language.highlight_text(&Rope::from(text.as_str()), 0..text.len());
|
||||||
|
let filter_start = detail.len() + 1;
|
||||||
|
let filter_end =
|
||||||
|
if let Some(end) = text.rfind('(').filter(|end| *end > filter_start) {
|
||||||
|
end
|
||||||
|
} else {
|
||||||
|
text.len()
|
||||||
|
};
|
||||||
|
|
||||||
return Some(CodeLabel {
|
return Some(CodeLabel {
|
||||||
filter_range: detail.len() + 1..text.rfind('(').unwrap_or(text.len()),
|
filter_range: filter_start..filter_end,
|
||||||
text,
|
text,
|
||||||
runs,
|
runs,
|
||||||
});
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user