mirror of
https://github.com/jesseduffield/lazygit.git
synced 2025-05-11 12:25:47 +02:00
Add key binding for switching from the commit message panel to an editor
This is useful for when you begin to type the message in lazygit's commit panel, and then realize that you'd rather use your editor's more powerful editing capabilities. Pressing <c-o> will take you right there.
This commit is contained in:
parent
7263630967
commit
61bd3e8dd2
8 changed files with 131 additions and 11 deletions
|
@ -104,6 +104,7 @@ func (self *WorkingTreeHelper) HandleCommitPressWithMessage(initialMessage strin
|
|||
DescriptionTitle: self.c.Tr.CommitDescriptionTitle,
|
||||
PreserveMessage: true,
|
||||
OnConfirm: self.handleCommit,
|
||||
OnSwitchToEditor: self.switchFromCommitMessagePanelToEditor,
|
||||
},
|
||||
)
|
||||
}
|
||||
|
@ -117,6 +118,21 @@ func (self *WorkingTreeHelper) handleCommit(summary string, description string)
|
|||
})
|
||||
}
|
||||
|
||||
func (self *WorkingTreeHelper) switchFromCommitMessagePanelToEditor(filepath string) error {
|
||||
// We won't be able to tell whether the commit was successful, because
|
||||
// RunSubprocessAndRefresh doesn't return the error (it opens an error alert
|
||||
// itself and returns nil on error). But even if we could, we wouldn't have
|
||||
// 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.c.LogAction(self.c.Tr.Actions.Commit)
|
||||
return self.c.RunSubprocessAndRefresh(
|
||||
self.c.Git().Commit.CommitInEditorWithMessageFileCmdObj(filepath),
|
||||
)
|
||||
}
|
||||
|
||||
// HandleCommitEditorPress - handle when the user wants to commit changes via
|
||||
// their editor rather than via the popup panel
|
||||
func (self *WorkingTreeHelper) HandleCommitEditorPress() error {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue