mirror of
https://github.com/jesseduffield/lazygit.git
synced 2025-05-27 23:08:02 +02:00
Clear preserved commit message when entering CommitEditorPanel (#4558)
- **PR Description** Fixes the problem described in #4557: I often find myself initiating a commit message with `c`, but then halfway through typing the message, realize that is is likely to be more substantial than I thought. I press `<esc>` and then `C` to launch my editor where I can edit a larger commit body more effectively. I finish my commit message, close my editor, return to LazyGit and all is well. Unfortunately, the next time I press `c`, creating a totally new commit, my partially completed message is still present. It no longer is relevant, so I have to delete the few words I typed before.
This commit is contained in:
commit
a0ec22c251
@ -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 {
|
||||
|
@ -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})
|
||||
}
|
||||
|
@ -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(),
|
||||
|
Loading…
x
Reference in New Issue
Block a user