From 0389235a15ab0a210db1f3eed04ddbafe01d9bcc Mon Sep 17 00:00:00 2001 From: Lukas Wirth Date: Sun, 5 Jan 2025 16:18:20 +0100 Subject: [PATCH] fix: Be more permissive with completion resolve data --- src/tools/rust-analyzer/crates/rust-analyzer/src/lsp/ext.rs | 5 +++++ src/tools/rust-analyzer/docs/dev/lsp-extensions.md | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/tools/rust-analyzer/crates/rust-analyzer/src/lsp/ext.rs b/src/tools/rust-analyzer/crates/rust-analyzer/src/lsp/ext.rs index e1677cbcda80..f50cbba7acfe 100644 --- a/src/tools/rust-analyzer/crates/rust-analyzer/src/lsp/ext.rs +++ b/src/tools/rust-analyzer/crates/rust-analyzer/src/lsp/ext.rs @@ -1,5 +1,9 @@ //! rust-analyzer extensions to the LSP. +// Note when adding new resolve payloads, add a #[serde(default)] on boolean fields as some clients +// might strip `false` values from the JSON payload due to their reserialization logic turning false +// into null which will then cause them to be omitted in the resolve request. See https://github.com/rust-lang/rust-analyzer/issues/18767 + #![allow(clippy::disallowed_types)] use std::ops; @@ -829,6 +833,7 @@ pub struct CompletionResolveData { pub version: Option, #[serde(skip_serializing_if = "Option::is_none", default)] pub trigger_character: Option, + #[serde(default)] pub for_ref: bool, pub hash: String, } diff --git a/src/tools/rust-analyzer/docs/dev/lsp-extensions.md b/src/tools/rust-analyzer/docs/dev/lsp-extensions.md index 826ce1124486..21ac3a5a2693 100644 --- a/src/tools/rust-analyzer/docs/dev/lsp-extensions.md +++ b/src/tools/rust-analyzer/docs/dev/lsp-extensions.md @@ -1,5 +1,5 @@