aboutsummaryrefslogtreecommitdiff
path: root/crates/rust-analyzer/src/reload.rs
diff options
context:
space:
mode:
authorAleksey Kladov <[email protected]>2021-04-12 14:09:21 +0100
committerAleksey Kladov <[email protected]>2021-04-12 14:19:36 +0100
commit29d5f29932eae4dcae589f2769e6a0f26c5ee4b9 (patch)
tree59dae2f1ee03ec35ab95f05ea4b5bb2506162652 /crates/rust-analyzer/src/reload.rs
parenta526d0a4b78b29fec4c2e8d5608ceaeec128f794 (diff)
fix: don't spam repeated error messages when `cargo check` fails
Conceptually, using a *message* here is wrong, because this is a "status", rather than "point in time" thing. But statuses are an LSP extension, while messages are stable. As a compromise, send message only for more critical `metadata` failures, and only once per state change.
Diffstat (limited to 'crates/rust-analyzer/src/reload.rs')
-rw-r--r--crates/rust-analyzer/src/reload.rs15
1 files changed, 8 insertions, 7 deletions
diff --git a/crates/rust-analyzer/src/reload.rs b/crates/rust-analyzer/src/reload.rs
index d0cc1b61a..e51532d88 100644
--- a/crates/rust-analyzer/src/reload.rs
+++ b/crates/rust-analyzer/src/reload.rs
@@ -100,10 +100,6 @@ impl GlobalState {
100 } 100 }
101 } 101 }
102 pub(crate) fn report_new_status_if_needed(&mut self) { 102 pub(crate) fn report_new_status_if_needed(&mut self) {
103 if !self.config.server_status_notification() {
104 return;
105 }
106
107 let mut status = lsp_ext::ServerStatusParams { 103 let mut status = lsp_ext::ServerStatusParams {
108 health: lsp_ext::Health::Ok, 104 health: lsp_ext::Health::Ok,
109 quiescent: self.is_quiescent(), 105 quiescent: self.is_quiescent(),
@@ -129,7 +125,14 @@ impl GlobalState {
129 125
130 if self.last_reported_status.as_ref() != Some(&status) { 126 if self.last_reported_status.as_ref() != Some(&status) {
131 self.last_reported_status = Some(status.clone()); 127 self.last_reported_status = Some(status.clone());
132 self.send_notification::<lsp_ext::ServerStatusNotification>(status); 128
129 if let (lsp_ext::Health::Error, Some(message)) = (status.health, &status.message) {
130 self.show_message(lsp_types::MessageType::Error, message.clone());
131 }
132
133 if self.config.server_status_notification() {
134 self.send_notification::<lsp_ext::ServerStatusNotification>(status);
135 }
133 } 136 }
134 } 137 }
135 138
@@ -225,7 +228,6 @@ impl GlobalState {
225 228
226 if let Some(error_message) = self.fetch_workspace_error() { 229 if let Some(error_message) = self.fetch_workspace_error() {
227 log::error!("failed to switch workspaces: {}", error_message); 230 log::error!("failed to switch workspaces: {}", error_message);
228 self.show_message(lsp_types::MessageType::Error, error_message);
229 if !self.workspaces.is_empty() { 231 if !self.workspaces.is_empty() {
230 return; 232 return;
231 } 233 }
@@ -233,7 +235,6 @@ impl GlobalState {
233 235
234 if let Some(error_message) = self.build_data_error() { 236 if let Some(error_message) = self.build_data_error() {
235 log::error!("failed to switch build data: {}", error_message); 237 log::error!("failed to switch build data: {}", error_message);
236 self.show_message(lsp_types::MessageType::Error, error_message);
237 } 238 }
238 239
239 let workspaces = self 240 let workspaces = self