diff options
author | Blaž Hrastnik | 2021-08-29 09:38:28 +0000 |
---|---|---|
committer | Blaž Hrastnik | 2021-08-29 09:38:28 +0000 |
commit | 847d1fa496f157c1a9640c5cedd92d6593e33b08 (patch) | |
tree | 665762af71c63bc718e085c022ce3929b4f0f3d3 /helix-lsp | |
parent | 7eff9056802d3d4f67fbaef7ba7dc03e874564c1 (diff) |
fix: Work around crashes on LSPs that don't just emit JSON-RPC
Diffstat (limited to 'helix-lsp')
-rw-r--r-- | helix-lsp/src/transport.rs | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/helix-lsp/src/transport.rs b/helix-lsp/src/transport.rs index 068ea230..67b7b48f 100644 --- a/helix-lsp/src/transport.rs +++ b/helix-lsp/src/transport.rs @@ -1,7 +1,7 @@ use crate::Result; -use anyhow::{anyhow, Context}; +use anyhow::Context; use jsonrpc_core as jsonrpc; -use log::{debug, error, info}; +use log::{debug, error, info, warn}; use serde::{Deserialize, Serialize}; use serde_json::Value; use std::collections::HashMap; @@ -92,7 +92,12 @@ impl Transport { content_length = Some(value.parse().context("invalid content length")?); } Some((_, _)) => {} - None => return Err(anyhow!("Failed to parse header: {:?}", header).into()), + None => { + // Workaround: Some non-conformant language servers will output logging and other garbage + // into the same stream as JSON-RPC messages. This can also happen from shell scripts that spawn + // the server. Skip such lines and log a warning. + warn!("Failed to parse header: {:?}", header); + } } } |