diff --git a/src/lsp/mod.rs b/src/lsp/mod.rs index 8140eb2..414e05f 100644 --- a/src/lsp/mod.rs +++ b/src/lsp/mod.rs @@ -107,13 +107,7 @@ impl Serialize for Message { wrapped.serialize(serializer) } - Self::Unknown(unknown) => { - let wrapped = WithJsonRpc { - jsonrpc: "2.0", - msg: &unknown, - }; - wrapped.serialize(serializer) - } + Self::Unknown(unknown) => unknown.serialize(serializer), } } } @@ -155,4 +149,12 @@ mod tests { let from_value: Message = serde_json::from_value(v).unwrap(); assert_eq!(from_str, from_value); } + + #[test] + fn test_serialize_unknown_notification() { + let v = json!({"jsonrpc":"2.0","method":"language/status","params":{"message":""}}); + let s = v.to_string(); + let from_value: Message = serde_json::from_value(v).unwrap(); + assert_eq!(serde_json::to_string(&from_value).unwrap(), s); + } } diff --git a/src/lsp/types.rs b/src/lsp/types.rs index 0af8345..40f496b 100644 --- a/src/lsp/types.rs +++ b/src/lsp/types.rs @@ -32,11 +32,4 @@ pub enum Params { /// Unknown message type. #[derive(Clone, Debug, PartialEq, Serialize, Deserialize)] -pub struct Unknown { - #[serde(default)] - pub id: Option, - #[serde(default)] - pub method: Option, - #[serde(skip_serializing_if = "Option::is_none")] - pub params: Option, -} +pub struct Unknown(serde_json::Value);