mirror of
https://github.com/helix-editor/helix.git
synced 2024-11-22 09:26:19 +04:00
prevent panic when receiving malformed LSP PublishDiagnostic (#2160)
Instead of panicing we can discard the malformed diagnostic. This `.parse()` fails commonly when a non-conformant language server gives a diagnostic with a location that breaks the spec: { "character": 0, "line": -1 } can currently be returned by ElixirLS and the python LS. Other messages in this block are discarded but this one feels special enough to log.
This commit is contained in:
parent
4b1fe367fa
commit
449d1dfdfb
@ -276,7 +276,13 @@ pub fn parse(method: &str, params: jsonrpc::Params) -> Option<Notification> {
|
||||
lsp::notification::PublishDiagnostics::METHOD => {
|
||||
let params: lsp::PublishDiagnosticsParams = params
|
||||
.parse()
|
||||
.expect("Failed to parse PublishDiagnostics params");
|
||||
.map_err(|err| {
|
||||
log::error!(
|
||||
"received malformed PublishDiagnostic from Language Server: {}",
|
||||
err
|
||||
)
|
||||
})
|
||||
.ok()?;
|
||||
|
||||
// TODO: need to loop over diagnostics and distinguish them by URI
|
||||
Self::PublishDiagnostics(params)
|
||||
|
Loading…
Reference in New Issue
Block a user