diff --git a/crates/git_ui/src/commit_modal.rs b/crates/git_ui/src/commit_modal.rs index 8305ee604e1fdfe0e342f097338b40995e65d143..822b2c8385c2d573ceb2dc2872a685c47ff51379 100644 --- a/crates/git_ui/src/commit_modal.rs +++ b/crates/git_ui/src/commit_modal.rs @@ -493,20 +493,18 @@ impl CommitModal { } fn on_commit(&mut self, _: &git::Commit, window: &mut Window, cx: &mut Context) { - if self - .git_panel - .update(cx, |git_panel, cx| git_panel.commit(window, cx)) - { + if self.git_panel.update(cx, |git_panel, cx| { + git_panel.commit(&self.commit_editor.focus_handle(cx), window, cx) + }) { telemetry::event!("Git Committed", source = "Git Modal"); cx.emit(DismissEvent); } } fn on_amend(&mut self, _: &git::Amend, window: &mut Window, cx: &mut Context) { - if self - .git_panel - .update(cx, |git_panel, cx| git_panel.amend(window, cx)) - { + if self.git_panel.update(cx, |git_panel, cx| { + git_panel.amend(&self.commit_editor.focus_handle(cx), window, cx) + }) { telemetry::event!("Git Amended", source = "Git Modal"); cx.emit(DismissEvent); } diff --git a/crates/git_ui/src/git_panel.rs b/crates/git_ui/src/git_panel.rs index e5b307da7b1683e1d5b453b35aab99303d0b3753..81d2a547bf11d91df98935efa0c167d28644e073 100644 --- a/crates/git_ui/src/git_panel.rs +++ b/crates/git_ui/src/git_panel.rs @@ -1935,7 +1935,7 @@ impl GitPanel { } fn on_commit(&mut self, _: &git::Commit, window: &mut Window, cx: &mut Context) { - if self.commit(window, cx) { + if self.commit(&self.commit_editor.focus_handle(cx), window, cx) { telemetry::event!("Git Committed", source = "Git Panel"); } } @@ -1943,16 +1943,17 @@ impl GitPanel { /// Commits staged changes with the current commit message. /// /// Returns `true` if the commit was executed, `false` otherwise. - pub(crate) fn commit(&mut self, window: &mut Window, cx: &mut Context) -> bool { + pub(crate) fn commit( + &mut self, + commit_editor_focus_handle: &FocusHandle, + window: &mut Window, + cx: &mut Context, + ) -> bool { if self.amend_pending { return false; } - if self - .commit_editor - .focus_handle(cx) - .contains_focused(window, cx) - { + if commit_editor_focus_handle.contains_focused(window, cx) { self.commit_changes( CommitOptions { amend: false, @@ -1969,7 +1970,7 @@ impl GitPanel { } fn on_amend(&mut self, _: &git::Amend, window: &mut Window, cx: &mut Context) { - if self.amend(window, cx) { + if self.amend(&self.commit_editor.focus_handle(cx), window, cx) { telemetry::event!("Git Amended", source = "Git Panel"); } } @@ -1979,12 +1980,13 @@ impl GitPanel { /// Uses a two-stage workflow where the first invocation loads the commit /// message for editing, second invocation performs the amend. Returns /// `true` if the amend was executed, `false` otherwise. - pub(crate) fn amend(&mut self, window: &mut Window, cx: &mut Context) -> bool { - if self - .commit_editor - .focus_handle(cx) - .contains_focused(window, cx) - { + pub(crate) fn amend( + &mut self, + commit_editor_focus_handle: &FocusHandle, + window: &mut Window, + cx: &mut Context, + ) -> bool { + if commit_editor_focus_handle.contains_focused(window, cx) { if self.head_commit(cx).is_some() { if !self.amend_pending { self.set_amend_pending(true, cx);