Fix a panic when git askpass triggers during commit (#50057)

Conrad Irwin created

Fixes ZED-597

Release Notes:

- Fixed a panic when the askpass dialogue opened while committing.

Change summary

crates/git_ui/src/git_panel.rs | 12 +++++-------
1 file changed, 5 insertions(+), 7 deletions(-)

Detailed changes

crates/git_ui/src/git_panel.rs 🔗

@@ -3171,18 +3171,16 @@ impl GitPanel {
         window: &mut Window,
         cx: &mut Context<Self>,
     ) -> AskPassDelegate {
-        let this = cx.weak_entity();
+        let workspace = self.workspace.clone();
         let operation = operation.into();
         let window = window.window_handle();
         AskPassDelegate::new(&mut cx.to_async(), move |prompt, tx, cx| {
             window
                 .update(cx, |_, window, cx| {
-                    this.update(cx, |this, cx| {
-                        this.workspace.update(cx, |workspace, cx| {
-                            workspace.toggle_modal(window, cx, |window, cx| {
-                                AskPassModal::new(operation.clone(), prompt.into(), tx, window, cx)
-                            });
-                        })
+                    workspace.update(cx, |workspace, cx| {
+                        workspace.toggle_modal(window, cx, |window, cx| {
+                            AskPassModal::new(operation.clone(), prompt.into(), tx, window, cx)
+                        });
                     })
                 })
                 .ok();