Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
Fix unstage/stage in project diff not working when git panel isn't open (#26575)
Anthony Eid74c29f1818eb
diff --git a/crates/git_ui/src/project_diff.rs b/crates/git_ui/src/project_diff.rsindex 6729f3fcfef..0e279ea0fe6 100644--- a/crates/git_ui/src/project_diff.rs+++ b/crates/git_ui/src/project_diff.rs@@ -815,23 +815,30 @@ impl ProjectDiffToolbar {cx.dispatch_action(action.as_ref());})}- fn dispatch_panel_action(- &self,- action: &dyn Action,- window: &mut Window,- cx: &mut Context<Self>,- ) {++ fn stage_all(&mut self, window: &mut Window, cx: &mut Context<Self>) {self.workspace- .read_with(cx, |workspace, cx| {+ .update(cx, |workspace, cx| {if let Some(panel) = workspace.panel::<GitPanel>(cx) {- panel.focus_handle(cx).focus(window)+ panel.update(cx, |panel, cx| {+ panel.stage_all(&Default::default(), window, cx);+ });}}).ok();- let action = action.boxed_clone();- cx.defer(move |cx| {- cx.dispatch_action(action.as_ref());- })+ }++ fn unstage_all(&mut self, window: &mut Window, cx: &mut Context<Self>) {+ self.workspace+ .update(cx, |workspace, cx| {+ let Some(panel) = workspace.panel::<GitPanel>(cx) else {+ return;+ };+ panel.update(cx, |panel, cx| {+ panel.unstage_all(&Default::default(), window, cx);+ });+ })+ .ok();}}@@ -985,7 +992,7 @@ impl Render for ProjectDiffToolbar {&focus_handle,)).on_click(cx.listener(|this, _, window, cx| {- this.dispatch_panel_action(&UnstageAll, window, cx)+ this.unstage_all(window, cx)})),)},@@ -1005,7 +1012,7 @@ impl Render for ProjectDiffToolbar {&focus_handle,)).on_click(cx.listener(|this, _, window, cx| {- this.dispatch_panel_action(&StageAll, window, cx)+ this.stage_all(window, cx)})),),)