Skip to content

Commit

Permalink
fix(diagnostics): absence of diagnostic should return None instead of…
Browse files Browse the repository at this point in the history
… empty Vec
  • Loading branch information
DrWursterich committed Apr 18, 2024
1 parent 2edf82e commit 15dddd2
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions src/command/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -102,17 +102,20 @@ pub(crate) fn diagnostic(request: Request) -> Result<Message> {
Message::Response(match diagnostic::diagnostic(params) {
Ok(diagnostic) => Response {
id: request.id,
result: serde_json::to_value(FullDocumentDiagnosticReport {
result_id: None,
items: diagnostic,
})
.ok(),
result: match diagnostic.len() {
0 => None,
_ => serde_json::to_value(FullDocumentDiagnosticReport {
result_id: None,
items: diagnostic,
})
.ok(),
},
error: None,
},
Err(err) => err.to_response(request.id),
})
})
.map_err(|err| Error::from(err));
.map_err(Error::from);
}

pub(crate) fn highlight(request: Request) -> Result<Message> {
Expand Down

0 comments on commit 15dddd2

Please sign in to comment.