Skip to content

Commit

Permalink
Merge pull request #34 from qualified/fix-ser-unknown-message
Browse files Browse the repository at this point in the history
  • Loading branch information
kazk authored May 11, 2022
2 parents 3a236e8 + c801162 commit 1f33f5a
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 15 deletions.
16 changes: 9 additions & 7 deletions src/lsp/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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),
}
}
}
Expand Down Expand Up @@ -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);
}
}
9 changes: 1 addition & 8 deletions src/lsp/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,4 @@ pub enum Params {

/// Unknown message type.
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
pub struct Unknown {
#[serde(default)]
pub id: Option<Id>,
#[serde(default)]
pub method: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
pub params: Option<Params>,
}
pub struct Unknown(serde_json::Value);

0 comments on commit 1f33f5a

Please sign in to comment.