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