diff --git a/pkg/gui/controllers/helpers/commits_helper.go b/pkg/gui/controllers/helpers/commits_helper.go index 9d2fcd164..5404ac5c5 100644 --- a/pkg/gui/controllers/helpers/commits_helper.go +++ b/pkg/gui/controllers/helpers/commits_helper.go @@ -157,11 +157,8 @@ func (self *CommitsHelper) OpenCommitMessagePanel(opts *OpenCommitMessagePanelOp self.c.Context().Push(self.c.Contexts().CommitMessage, types.OnFocusOpts{}) } -func (self *CommitsHelper) OnCommitSuccess() { - // if we have a preserved message we want to clear it on success - if self.c.Contexts().CommitMessage.GetPreserveMessage() { - self.c.Contexts().CommitMessage.SetPreservedMessageAndLogError("") - } +func (self *CommitsHelper) ClearPreservedCommitMessage() { + self.c.Contexts().CommitMessage.SetPreservedMessageAndLogError("") } func (self *CommitsHelper) HandleCommitConfirm() error { diff --git a/pkg/gui/controllers/helpers/tags_helper.go b/pkg/gui/controllers/helpers/tags_helper.go index dccc26e00..022b7969b 100644 --- a/pkg/gui/controllers/helpers/tags_helper.go +++ b/pkg/gui/controllers/helpers/tags_helper.go @@ -34,7 +34,6 @@ func (self *TagsHelper) OpenCreateTagPrompt(ref string, onCreate func()) error { } return self.gpg.WithGpgHandling(command, git_commands.TagGpgSign, self.c.Tr.CreatingTag, func() error { - self.commitsHelper.OnCommitSuccess() return nil }, []types.RefreshableView{types.COMMITS, types.TAGS}) } diff --git a/pkg/gui/controllers/helpers/working_tree_helper.go b/pkg/gui/controllers/helpers/working_tree_helper.go index 4d0d1e9da..9bff3dbc7 100644 --- a/pkg/gui/controllers/helpers/working_tree_helper.go +++ b/pkg/gui/controllers/helpers/working_tree_helper.go @@ -112,7 +112,7 @@ func (self *WorkingTreeHelper) handleCommit(summary string, description string, self.c.LogAction(self.c.Tr.Actions.Commit) return self.gpgHelper.WithGpgHandling(cmdObj, git_commands.CommitGpgSign, self.c.Tr.CommittingStatus, func() error { - self.commitsHelper.OnCommitSuccess() + self.commitsHelper.ClearPreservedCommitMessage() return nil }, nil) } @@ -124,7 +124,7 @@ func (self *WorkingTreeHelper) switchFromCommitMessagePanelToEditor(filepath str // access to the last message that the user typed, and it might be very // different from what was last in the commit panel. So the best we can do // here is to always clear the remembered commit message. - self.commitsHelper.OnCommitSuccess() + self.commitsHelper.ClearPreservedCommitMessage() self.c.LogAction(self.c.Tr.Actions.Commit) return self.c.RunSubprocessAndRefresh( @@ -136,6 +136,10 @@ func (self *WorkingTreeHelper) switchFromCommitMessagePanelToEditor(filepath str // their editor rather than via the popup panel func (self *WorkingTreeHelper) HandleCommitEditorPress() error { return self.WithEnsureCommittableFiles(func() error { + // See reasoning in switchFromCommitMessagePanelToEditor for why it makes sense + // to clear this message before calling into the editor + self.commitsHelper.ClearPreservedCommitMessage() + self.c.LogAction(self.c.Tr.Actions.Commit) return self.c.RunSubprocessAndRefresh( self.c.Git().Commit.CommitEditorCmdObj(),