mirror of
https://github.com/rust-lang/rust-analyzer
synced 2024-12-26 04:53:34 +00:00
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.
This commit is contained in:
parent
a526d0a4b7
commit
29d5f29932
1 changed files with 8 additions and 7 deletions
|
@ -100,10 +100,6 @@ impl GlobalState {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
pub(crate) fn report_new_status_if_needed(&mut self) {
|
pub(crate) fn report_new_status_if_needed(&mut self) {
|
||||||
if !self.config.server_status_notification() {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
let mut status = lsp_ext::ServerStatusParams {
|
let mut status = lsp_ext::ServerStatusParams {
|
||||||
health: lsp_ext::Health::Ok,
|
health: lsp_ext::Health::Ok,
|
||||||
quiescent: self.is_quiescent(),
|
quiescent: self.is_quiescent(),
|
||||||
|
@ -129,7 +125,14 @@ impl GlobalState {
|
||||||
|
|
||||||
if self.last_reported_status.as_ref() != Some(&status) {
|
if self.last_reported_status.as_ref() != Some(&status) {
|
||||||
self.last_reported_status = Some(status.clone());
|
self.last_reported_status = Some(status.clone());
|
||||||
self.send_notification::<lsp_ext::ServerStatusNotification>(status);
|
|
||||||
|
if let (lsp_ext::Health::Error, Some(message)) = (status.health, &status.message) {
|
||||||
|
self.show_message(lsp_types::MessageType::Error, message.clone());
|
||||||
|
}
|
||||||
|
|
||||||
|
if self.config.server_status_notification() {
|
||||||
|
self.send_notification::<lsp_ext::ServerStatusNotification>(status);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -225,7 +228,6 @@ impl GlobalState {
|
||||||
|
|
||||||
if let Some(error_message) = self.fetch_workspace_error() {
|
if let Some(error_message) = self.fetch_workspace_error() {
|
||||||
log::error!("failed to switch workspaces: {}", error_message);
|
log::error!("failed to switch workspaces: {}", error_message);
|
||||||
self.show_message(lsp_types::MessageType::Error, error_message);
|
|
||||||
if !self.workspaces.is_empty() {
|
if !self.workspaces.is_empty() {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -233,7 +235,6 @@ impl GlobalState {
|
||||||
|
|
||||||
if let Some(error_message) = self.build_data_error() {
|
if let Some(error_message) = self.build_data_error() {
|
||||||
log::error!("failed to switch build data: {}", error_message);
|
log::error!("failed to switch build data: {}", error_message);
|
||||||
self.show_message(lsp_types::MessageType::Error, error_message);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
let workspaces = self
|
let workspaces = self
|
||||||
|
|
Loading…
Reference in a new issue