Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
diagnostics: Ensure that clean state is not shown when tab content indicates problems in workspace (#25345)
Piotr Osiewiczc90f87898a81
diff --git a/crates/diagnostics/src/diagnostics.rs b/crates/diagnostics/src/diagnostics.rsindex a5183037adc..76606f54a77 100644--- a/crates/diagnostics/src/diagnostics.rs+++ b/crates/diagnostics/src/diagnostics.rs@@ -88,15 +88,46 @@ const DIAGNOSTICS_UPDATE_DEBOUNCE: Duration = Duration::from_millis(50);impl Render for ProjectDiagnosticsEditor {fn render(&mut self, _: &mut Window, cx: &mut Context<Self>) -> impl IntoElement {- let child = if self.path_states.is_empty() {- div()+ let warning_count = if self.include_warnings {+ self.summary.warning_count+ } else {+ 0+ };++ let child = if warning_count + self.summary.error_count == 0 {+ let label = if self.summary.warning_count == 0 {+ SharedString::new_static("No problems in workspace")+ } else {+ SharedString::new_static("No errors in workspace")+ };+ v_flex().key_context("EmptyPane")- .bg(cx.theme().colors().editor_background)- .flex()- .items_center()- .justify_center().size_full()- .child(Label::new("No problems in workspace"))+ .gap_1()+ .justify_center()+ .items_center()+ .text_center()+ .bg(cx.theme().colors().editor_background)+ .child(Label::new(label).color(Color::Muted))+ .when(self.summary.warning_count > 0, |this| {+ let plural_suffix = if self.summary.warning_count > 1 {+ "s"+ } else {+ ""+ };+ let label = format!(+ "Show {} warning{}",+ self.summary.warning_count, plural_suffix+ );+ this.child(+ Button::new("diagnostics-show-warning-label", label).on_click(cx.listener(+ |this, _, window, cx| {+ this.toggle_warnings(&Default::default(), window, cx);+ cx.notify();+ },+ )),+ )+ })} else {div().size_full().child(self.editor.clone())};