diff --git a/crates/rust-analyzer/src/lsp/ext.rs b/crates/rust-analyzer/src/lsp/ext.rs index df06270a8b..c0173d9c24 100644 --- a/crates/rust-analyzer/src/lsp/ext.rs +++ b/crates/rust-analyzer/src/lsp/ext.rs @@ -823,8 +823,11 @@ impl Request for OnTypeFormatting { #[derive(Debug, Serialize, Deserialize)] pub struct CompletionResolveData { pub position: lsp_types::TextDocumentPositionParams, + #[serde(skip_serializing_if = "Vec::is_empty", default)] pub imports: Vec, + #[serde(skip_serializing_if = "Option::is_none", default)] pub version: Option, + #[serde(skip_serializing_if = "Option::is_none", default)] pub trigger_character: Option, pub for_ref: bool, pub hash: String, @@ -836,6 +839,7 @@ pub struct InlayHintResolveData { // This is a string instead of a u64 as javascript can't represent u64 fully pub hash: String, pub resolve_range: lsp_types::Range, + #[serde(skip_serializing_if = "Option::is_none", default)] pub version: Option, } diff --git a/crates/rust-analyzer/src/lsp/to_proto.rs b/crates/rust-analyzer/src/lsp/to_proto.rs index 612cb547b4..c3e7543d92 100644 --- a/crates/rust-analyzer/src/lsp/to_proto.rs +++ b/crates/rust-analyzer/src/lsp/to_proto.rs @@ -2,6 +2,7 @@ use std::{ iter::once, mem, + ops::Not as _, sync::atomic::{AtomicU32, Ordering}, }; @@ -358,9 +359,12 @@ fn completion_item( filter_text, kind: Some(completion_item_kind(item.kind)), text_edit, - additional_text_edits: Some(additional_text_edits), + additional_text_edits: additional_text_edits + .is_empty() + .not() + .then_some(additional_text_edits), documentation, - deprecated: Some(item.deprecated), + deprecated: item.deprecated.then_some(item.deprecated), tags, command, insert_text_format, @@ -370,7 +374,7 @@ fn completion_item( if config.completion_label_details_support() { if fields_to_resolve.resolve_label_details { something_to_resolve |= true; - } else { + } else if item.label_detail.is_some() || item.detail.is_some() { lsp_item.label_details = Some(lsp_types::CompletionItemLabelDetails { detail: item.label_detail.as_ref().map(ToString::to_string), description: item.detail.clone(), diff --git a/docs/dev/lsp-extensions.md b/docs/dev/lsp-extensions.md index 2aad2cfa36..0e37611a54 100644 --- a/docs/dev/lsp-extensions.md +++ b/docs/dev/lsp-extensions.md @@ -1,5 +1,5 @@