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 <kirill@zed.dev>
This commit is contained in:
RainandKirill Bulatov authored and GitHub committed 2026-07-08 12:08:36 +00:00
1 parent bb021d2004
commit 9efc6f5e16
1 file changed
+29 -3
+29 -3
View File
@@ -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"));
}
}