Fix panic when diagnostics first opens (#28935)

Conrad Irwin created

Closes #ISSUE

Release Notes:

- N/A

Change summary

crates/diagnostics/src/diagnostics.rs | 1 +
crates/diagnostics/src/items.rs       | 6 +++---
2 files changed, 4 insertions(+), 3 deletions(-)

Detailed changes

crates/diagnostics/src/diagnostics.rs 🔗

@@ -46,6 +46,7 @@ use workspace::{
 
 actions!(diagnostics, [Deploy, ToggleWarnings]);
 
+#[derive(Default)]
 pub(crate) struct IncludeWarnings(bool);
 impl Global for IncludeWarnings {}
 

crates/diagnostics/src/items.rs 🔗

@@ -95,9 +95,9 @@ impl Render for DiagnosticIndicator {
                     .on_click(cx.listener(|this, _, window, cx| {
                         if let Some(workspace) = this.workspace.upgrade() {
                             if this.summary.error_count == 0 && this.summary.warning_count > 0 {
-                                cx.update_global(|show_warnings: &mut IncludeWarnings, _| {
-                                    show_warnings.0 = true
-                                });
+                                cx.update_default_global(
+                                    |show_warnings: &mut IncludeWarnings, _| show_warnings.0 = true,
+                                );
                             }
                             workspace.update(cx, |workspace, cx| {
                                 ProjectDiagnosticsEditor::deploy(