rust: Nicer snippet completions (#43891)
At some point, rust-analyzer started including the snippet expression for some completions in the description field, but that can look like a bug: <img width="1570" height="578" alt="CleanShot 2025-11-27 at 20 39 49@2x" src="https://github.com/user-attachments/assets/5a87c9fe-c0a8-472f-8d83-3bc9e9e00bbc"></img> In these cases, we will now inline the tab stops as an ellipsis character: <img width="1544" height="428" alt="CleanShot 2025-12-01 at 10 01 18@2x" src="https://github.com/user-attachments/assets/4c550891-4545-47cd-a295-a5eb07e78e92"></img> You may also notice that we now syntax highlight the pattern closer to what it looks like after accepted. Alternatively, when the tab stop isn't just one position, it gets highlighted as a selection since that's what it would do when accepted: <img width="1558" height="314" alt="CleanShot 2025-12-01 at 10 04 37@2x" src="https://github.com/user-attachments/assets/ce630ab2-da22-4072-a996-7b71ba21637d" /> Release Notes: - rust: Display completion tab stops inline rather than as a raw LSP snippet expression
This commit is contained in:
@@ -835,36 +835,38 @@ impl CompletionsMenu {
|
||||
FontWeight::BOLD.into(),
|
||||
)
|
||||
}),
|
||||
styled_runs_for_code_label(&completion.label, &style.syntax).map(
|
||||
|(range, mut highlight)| {
|
||||
// Ignore font weight for syntax highlighting, as we'll use it
|
||||
// for fuzzy matches.
|
||||
highlight.font_weight = None;
|
||||
if completion
|
||||
.source
|
||||
.lsp_completion(false)
|
||||
.and_then(|lsp_completion| {
|
||||
match (lsp_completion.deprecated, &lsp_completion.tags)
|
||||
{
|
||||
(Some(true), _) => Some(true),
|
||||
(_, Some(tags)) => Some(
|
||||
tags.contains(&CompletionItemTag::DEPRECATED),
|
||||
),
|
||||
_ => None,
|
||||
styled_runs_for_code_label(
|
||||
&completion.label,
|
||||
&style.syntax,
|
||||
&style.local_player,
|
||||
)
|
||||
.map(|(range, mut highlight)| {
|
||||
// Ignore font weight for syntax highlighting, as we'll use it
|
||||
// for fuzzy matches.
|
||||
highlight.font_weight = None;
|
||||
if completion
|
||||
.source
|
||||
.lsp_completion(false)
|
||||
.and_then(|lsp_completion| {
|
||||
match (lsp_completion.deprecated, &lsp_completion.tags) {
|
||||
(Some(true), _) => Some(true),
|
||||
(_, Some(tags)) => {
|
||||
Some(tags.contains(&CompletionItemTag::DEPRECATED))
|
||||
}
|
||||
})
|
||||
.unwrap_or(false)
|
||||
{
|
||||
highlight.strikethrough = Some(StrikethroughStyle {
|
||||
thickness: 1.0.into(),
|
||||
..Default::default()
|
||||
});
|
||||
highlight.color = Some(cx.theme().colors().text_muted);
|
||||
}
|
||||
_ => None,
|
||||
}
|
||||
})
|
||||
.unwrap_or(false)
|
||||
{
|
||||
highlight.strikethrough = Some(StrikethroughStyle {
|
||||
thickness: 1.0.into(),
|
||||
..Default::default()
|
||||
});
|
||||
highlight.color = Some(cx.theme().colors().text_muted);
|
||||
}
|
||||
|
||||
(range, highlight)
|
||||
},
|
||||
),
|
||||
(range, highlight)
|
||||
}),
|
||||
);
|
||||
|
||||
let completion_label = StyledText::new(completion.label.text.clone())
|
||||
|
||||
Reference in New Issue
Block a user