Fix unstage/stage in project diff not working when git panel isn't open (#26575)
Closes #ISSUE Release Notes: - Fix Bug where unstage/stage all in project diff wouldn't work while git panel was closed Co-authored-by: Conrad Irwin <conrad.irwin@gmail.com>
This commit is contained in:
parent
5858e61327
commit
74c29f1818
1 changed files with 21 additions and 14 deletions
|
@ -815,23 +815,30 @@ impl ProjectDiffToolbar {
|
||||||
cx.dispatch_action(action.as_ref());
|
cx.dispatch_action(action.as_ref());
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
fn dispatch_panel_action(
|
|
||||||
&self,
|
fn stage_all(&mut self, window: &mut Window, cx: &mut Context<Self>) {
|
||||||
action: &dyn Action,
|
|
||||||
window: &mut Window,
|
|
||||||
cx: &mut Context<Self>,
|
|
||||||
) {
|
|
||||||
self.workspace
|
self.workspace
|
||||||
.read_with(cx, |workspace, cx| {
|
.update(cx, |workspace, cx| {
|
||||||
if let Some(panel) = workspace.panel::<GitPanel>(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();
|
.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,
|
&focus_handle,
|
||||||
))
|
))
|
||||||
.on_click(cx.listener(|this, _, window, cx| {
|
.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,
|
&focus_handle,
|
||||||
))
|
))
|
||||||
.on_click(cx.listener(|this, _, window, cx| {
|
.on_click(cx.listener(|this, _, window, cx| {
|
||||||
this.dispatch_panel_action(&StageAll, window, cx)
|
this.stage_all(window, cx)
|
||||||
})),
|
})),
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue