Skip to content

Commit 35da60a

Browse files
committed
Auto merge of rust-lang#15962 - ahlinc:label-datail2, r=lnicola
fix: add fallback for completion label details This PR adds a fallback to a previous implementation in a case when the label detail field isn't supported by LSP client and the support isn't reported by the LSP initialize request. In this case additional info about trait and aliases would be merged into the label field as it was before the rust-lang#15956 PR.
2 parents 34cffbf + 94cea46 commit 35da60a

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed

Diff for: crates/ide-completion/src/item.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ use crate::{
2626
pub struct CompletionItem {
2727
/// Label in the completion pop up which identifies completion.
2828
pub label: SmolStr,
29-
/// Addition label details in the completion pop up that are
29+
/// Additional label details in the completion pop up that are
3030
/// displayed and aligned on the right side after the label.
3131
pub label_detail: Option<SmolStr>,
3232

Diff for: crates/rust-analyzer/src/lsp/to_proto.rs

+2
Original file line numberDiff line numberDiff line change
@@ -304,6 +304,8 @@ fn completion_item(
304304
detail: item.label_detail.as_ref().map(ToString::to_string),
305305
description: lsp_item.detail.clone(),
306306
});
307+
} else if let Some(label_detail) = item.label_detail {
308+
lsp_item.label.push_str(label_detail.as_str());
307309
}
308310

309311
set_score(&mut lsp_item, max_relevance, item.relevance);

0 commit comments

Comments
 (0)