Unnamed repository; edit this file 'description' to name the repository.
Diffstat (limited to 'helix-lsp/src/transport.rs')
| -rw-r--r-- | helix-lsp/src/transport.rs | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/helix-lsp/src/transport.rs b/helix-lsp/src/transport.rs index 088c617b..fa4966c4 100644 --- a/helix-lsp/src/transport.rs +++ b/helix-lsp/src/transport.rs @@ -98,7 +98,7 @@ impl Transport { buffer.clear(); if reader.read_line(buffer).await? == 0 { return Err(Error::StreamClosed); - }; + } // debug!("<- header {:?}", buffer); @@ -133,12 +133,14 @@ impl Transport { info!("{language_server_name} <- {msg}"); - // try parsing as output (server response) or call (server request) - let output: serde_json::Result<ServerMessage> = serde_json::from_str(msg); + // NOTE: We avoid using `?` here, since it would return early on error + // and skip clearing `content`. By returning the result directly instead, + // we ensure `content.clear()` is always called. + let output = sonic_rs::from_slice(content).map_err(Into::into); content.clear(); - Ok(output?) + output } async fn recv_server_error( |