From e8479f23f9e0a43d1eb4c91c935950cf035c01da Mon Sep 17 00:00:00 2001 From: Max Brunsfeld Date: Tue, 6 Jun 2023 17:13:49 -0700 Subject: [PATCH] Improve log message on invalid LSP message from server's stdout --- crates/lsp/src/lsp.rs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/crates/lsp/src/lsp.rs b/crates/lsp/src/lsp.rs index 1b01660308..691203d5e8 100644 --- a/crates/lsp/src/lsp.rs +++ b/crates/lsp/src/lsp.rs @@ -260,9 +260,10 @@ impl LanguageServer { buffer.clear(); stdout.read_until(b'\n', &mut buffer).await?; stdout.read_until(b'\n', &mut buffer).await?; - let message_len: usize = std::str::from_utf8(&buffer)? + let header = std::str::from_utf8(&buffer)?; + let message_len: usize = header .strip_prefix(CONTENT_LEN_HEADER) - .ok_or_else(|| anyhow!("invalid header"))? + .ok_or_else(|| anyhow!("invalid LSP message header {header:?}"))? .trim_end() .parse()?; @@ -301,7 +302,7 @@ impl LanguageServer { } } else { warn!( - "Failed to deserialize message:\n{}", + "failed to deserialize LSP message:\n{}", std::str::from_utf8(&buffer)? ); }