From 718e0a9851814ce336f08a508489299498d4768f Mon Sep 17 00:00:00 2001 From: "gcp-cherry-pick-bot[bot]" <98988430+gcp-cherry-pick-bot[bot]@users.noreply.github.com> Date: Wed, 16 Apr 2025 22:26:12 -0600 Subject: [PATCH] Fix panic when diagnostics first opens (cherry-pick #28935) (#28939) Cherry-picked Fix panic when diagnostics first opens (#28935) Closes #ISSUE Release Notes: - N/A Co-authored-by: Conrad Irwin --- crates/diagnostics/src/diagnostics.rs | 1 + crates/diagnostics/src/items.rs | 6 +++--- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/crates/diagnostics/src/diagnostics.rs b/crates/diagnostics/src/diagnostics.rs index bfe5ecbe63ae14770663d075e24178d59ba05b3c..fc4dcba3c3fa0c80d53db4c238198951d0a2f2f5 100644 --- a/crates/diagnostics/src/diagnostics.rs +++ b/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 {} diff --git a/crates/diagnostics/src/items.rs b/crates/diagnostics/src/items.rs index adf2c8e300de4a4375b334b72585d370df203c11..26a6c75357c2a9f2870cd7e4333aae8109711d38 100644 --- a/crates/diagnostics/src/items.rs +++ b/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(