From 9efc6f5e16cbccf8c9e7003d47e90b27f8d23a05 Mon Sep 17 00:00:00 2001 From: Rain Date: Wed, 8 Jul 2026 05:08:36 -0700 Subject: [PATCH] Fix should_log_lsp_request_failure logic inversion (#57554) Was trying to debug an r-a issue and ran into this. Self-Review Checklist: - [x] I've reviewed my own diff for quality, security, and reliabilityx - [x] Unsafe blocks (if any) have justifying comments - [x] The content is consistent with the [UI/UX checklist](https://github.com/zed-industries/zed/blob/main/CONTRIBUTING.md#uiux-checklist) - [x] Tests cover the new/changed behavior - [x] Performance impact has been considered and is acceptable Closes #ISSUE Release Notes: - N/A or Added/Fixed/Improved ... Co-authored-by: Kirill Bulatov --- crates/project/src/lsp_store.rs | 32 +++++++++++++++++++++++++++++--- 1 file changed, 29 insertions(+), 3 deletions(-) diff --git a/crates/project/src/lsp_store.rs b/crates/project/src/lsp_store.rs index 96f02fcb77..2a95034cba 100644 --- a/crates/project/src/lsp_store.rs +++ b/crates/project/src/lsp_store.rs @@ -4225,9 +4225,10 @@ impl SymbolLocation { } fn should_log_lsp_request_failure(message: &str) -> bool { - // content modified is a weird failure mode of rust-analyzer - // where requests are denied before its loaded a project - message.ends_with("content modified") || message.ends_with("server cancelled the request") + // "content modified" and "server cancelled the request" are noisy failure + // modes of rust-analyzer where requests are denied before it has loaded a + // project. + !(message.ends_with("content modified") || message.ends_with("server cancelled the request")) } impl LspStore { @@ -15312,3 +15313,28 @@ fn extend_formatting_transaction( Ok(()) }) } + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn should_log_lsp_request_failure_suppresses_known_noise() { + // Suppressed: rust-analyzer's superseded/denied request signals. + assert!(!should_log_lsp_request_failure( + "Get diagnostics via rust-analyzer failed: content modified" + )); + assert!(!should_log_lsp_request_failure( + "Get diagnostics via rust-analyzer failed: server cancelled the request" + )); + + // Logged: anything else is a real failure. + assert!(should_log_lsp_request_failure( + "Get diagnostics via rust-analyzer failed: server shut down" + )); + assert!(should_log_lsp_request_failure( + "Get diagnostics via rust-analyzer failed: Server reset the connection" + )); + assert!(should_log_lsp_request_failure("something else entirely")); + } +}