Skip to content

armgit / zed

Public Imported from GitHub
0

Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.

Fix should_log_lsp_request_failure logic inversion (#57554)

Rain01235732e683
diff --git a/crates/project/src/lsp_store.rs b/crates/project/src/lsp_store.rs
index 96f02fcb778..2a95034cbaa 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"));
+ }
+}