From c8f16760c763a95007e2cb2ca49a0abdedf82438 Mon Sep 17 00:00:00 2001 From: "zed-zippy[bot]" <234243425+zed-zippy[bot]@users.noreply.github.com> Date: Fri, 14 Nov 2025 09:54:31 +0000 Subject: [PATCH] git_panel: Fix StageAll/UnstageAll not working when panel not in focus (#42708) (cherry-pick to preview) (#42711) Cherry-pick of #42708 to preview ---- Release Notes: - Fixed "Stage All"/"Unstage All" buttons from not working when git panel is not in focus Co-authored-by: Jakub Konka --- crates/git_ui/src/git_panel.rs | 32 +++++++++++++++----------------- 1 file changed, 15 insertions(+), 17 deletions(-) diff --git a/crates/git_ui/src/git_panel.rs b/crates/git_ui/src/git_panel.rs index 81732732aff257b513faaf5f87ce85596a842dd8..4cf095879fe07b53640710cb9a3547c70aaec11c 100644 --- a/crates/git_ui/src/git_panel.rs +++ b/crates/git_ui/src/git_panel.rs @@ -3224,18 +3224,12 @@ impl GitPanel { ) -> Option { self.active_repository.as_ref()?; - let text; - let action; - let tooltip; - if self.total_staged_count() == self.entry_count && self.entry_count > 0 { - text = "Unstage All"; - action = git::UnstageAll.boxed_clone(); - tooltip = "git reset"; - } else { - text = "Stage All"; - action = git::StageAll.boxed_clone(); - tooltip = "git add --all ." - } + let (text, action, stage, tooltip) = + if self.total_staged_count() == self.entry_count && self.entry_count > 0 { + ("Unstage All", UnstageAll.boxed_clone(), false, "git reset") + } else { + ("Stage All", StageAll.boxed_clone(), true, "git add --all") + }; let change_string = match self.entry_count { 0 => "No Changes".to_string(), @@ -3273,11 +3267,15 @@ impl GitPanel { &self.focus_handle, )) .disabled(self.entry_count == 0) - .on_click(move |_, _, cx| { - let action = action.boxed_clone(); - cx.defer(move |cx| { - cx.dispatch_action(action.as_ref()); - }) + .on_click({ + let git_panel = cx.weak_entity(); + move |_, _, cx| { + git_panel + .update(cx, |git_panel, cx| { + git_panel.change_all_files_stage(stage, cx); + }) + .ok(); + } }), ), ),