Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
Open diagnostics editor faster when fetching cargo diagnostics (#29787)
Kirill Bulatov33011f2eafe0
diff --git a/crates/diagnostics/src/diagnostics.rs b/crates/diagnostics/src/diagnostics.rsindex d9a257e8820..46a1821023e 100644--- a/crates/diagnostics/src/diagnostics.rs+++ b/crates/diagnostics/src/diagnostics.rs@@ -226,7 +226,7 @@ impl ProjectDiagnosticsEditor {cx.observe_global_in::<IncludeWarnings>(window, |this, window, cx| {this.include_warnings = cx.global::<IncludeWarnings>().0;this.diagnostics.clear();- this.update_all_diagnostics(window, cx);+ this.update_all_diagnostics(false, window, cx);}).detach();cx.observe_release(&cx.entity(), |editor, _, cx| {@@ -254,7 +254,7 @@ impl ProjectDiagnosticsEditor {},_subscription: project_event_subscription,};- this.update_all_diagnostics(window, cx);+ this.update_all_diagnostics(true, window, cx);this}@@ -346,13 +346,13 @@ impl ProjectDiagnosticsEditor {if self.cargo_diagnostics_fetch.fetch_task.is_some() {self.stop_cargo_diagnostics_fetch(cx);} else {- self.update_all_diagnostics(window, cx);+ self.update_all_diagnostics(false, window, cx);}} else {if self.update_excerpts_task.is_some() {self.update_excerpts_task = None;} else {- self.update_all_diagnostics(window, cx);+ self.update_all_diagnostics(false, window, cx);}}cx.notify();@@ -371,10 +371,17 @@ impl ProjectDiagnosticsEditor {}}- fn update_all_diagnostics(&mut self, window: &mut Window, cx: &mut Context<Self>) {+ fn update_all_diagnostics(+ &mut self,+ first_launch: bool,+ window: &mut Window,+ cx: &mut Context<Self>,+ ) {let cargo_diagnostics_sources = self.cargo_diagnostics_sources(cx);if cargo_diagnostics_sources.is_empty() {self.update_all_excerpts(window, cx);+ } else if first_launch && !self.summary.is_empty() {+ self.update_all_excerpts(window, cx);} else {self.fetch_cargo_diagnostics(Arc::new(cargo_diagnostics_sources), cx);}