mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-28 04:44:57 +00:00
Update tests
This commit is contained in:
parent
615abb3c92
commit
f0adf8c4ec
2 changed files with 21 additions and 4 deletions
|
@ -150,16 +150,29 @@ fn render_completion_list(completions: Vec<CompletionItem>) -> String {
|
|||
fn monospace_width(s: &str) -> usize {
|
||||
s.chars().count()
|
||||
}
|
||||
let label_width =
|
||||
completions.iter().map(|it| monospace_width(&it.label)).max().unwrap_or_default().min(22);
|
||||
let label_width = completions
|
||||
.iter()
|
||||
.map(|it| {
|
||||
monospace_width(&it.label)
|
||||
+ monospace_width(it.label_detail.as_deref().unwrap_or_default())
|
||||
})
|
||||
.max()
|
||||
.unwrap_or_default()
|
||||
.min(22);
|
||||
completions
|
||||
.into_iter()
|
||||
.map(|it| {
|
||||
let tag = it.kind.tag();
|
||||
let var_name = format!("{tag} {}", it.label);
|
||||
let mut buf = var_name;
|
||||
if let Some(ref label_detail) = it.label_detail {
|
||||
format_to!(buf, "{label_detail}");
|
||||
}
|
||||
if let Some(detail) = it.detail {
|
||||
let width = label_width.saturating_sub(monospace_width(&it.label));
|
||||
let width = label_width.saturating_sub(
|
||||
monospace_width(&it.label)
|
||||
+ monospace_width(&it.label_detail.unwrap_or_default()),
|
||||
);
|
||||
format_to!(buf, "{:width$} {}", "", detail, width = width);
|
||||
}
|
||||
if it.deprecated {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue