diff options
| author | bors <bors@rust-lang.org> | 2023-11-25 11:54:36 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2023-11-25 11:54:36 +0000 |
| commit | 35da60a2bc143cfd6e7ee33d6d3c4b4234d0576e (patch) | |
| tree | a31d6d5ede39ea0a5aa2ce96e5dbaeea0125b822 | |
| parent | 34cffbf1d75fb6b5cb6bc68a9854b20dc74f135d (diff) | |
| parent | 94cea4663a3a826beccfeb291187df4849fe990e (diff) | |
| download | rust-35da60a2bc143cfd6e7ee33d6d3c4b4234d0576e.tar.gz rust-35da60a2bc143cfd6e7ee33d6d3c4b4234d0576e.zip | |
Auto merge of #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 #15956 PR.
| -rw-r--r-- | crates/ide-completion/src/item.rs | 2 | ||||
| -rw-r--r-- | crates/rust-analyzer/src/lsp/to_proto.rs | 2 |
2 files changed, 3 insertions, 1 deletions
diff --git a/crates/ide-completion/src/item.rs b/crates/ide-completion/src/item.rs index 5397a9fc90b..99b895eed4d 100644 --- a/crates/ide-completion/src/item.rs +++ b/crates/ide-completion/src/item.rs @@ -26,7 +26,7 @@ use crate::{ pub struct CompletionItem { /// Label in the completion pop up which identifies completion. pub label: SmolStr, - /// Addition label details in the completion pop up that are + /// Additional label details in the completion pop up that are /// displayed and aligned on the right side after the label. pub label_detail: Option<SmolStr>, diff --git a/crates/rust-analyzer/src/lsp/to_proto.rs b/crates/rust-analyzer/src/lsp/to_proto.rs index b4ba5bf4f91..fb366fd5cc4 100644 --- a/crates/rust-analyzer/src/lsp/to_proto.rs +++ b/crates/rust-analyzer/src/lsp/to_proto.rs @@ -304,6 +304,8 @@ fn completion_item( detail: item.label_detail.as_ref().map(ToString::to_string), description: lsp_item.detail.clone(), }); + } else if let Some(label_detail) = item.label_detail { + lsp_item.label.push_str(label_detail.as_str()); } set_score(&mut lsp_item, max_relevance, item.relevance); |
