mirror of
https://github.com/jesseduffield/lazygit.git
synced 2025-07-30 03:23:08 +03: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:
@ -279,10 +279,37 @@ func (self *LocalCommitsController) reword(commit *models.Commit) error {
|
||||
DescriptionTitle: self.c.Tr.CommitDescriptionTitle,
|
||||
PreserveMessage: false,
|
||||
OnConfirm: self.handleReword,
|
||||
OnSwitchToEditor: self.switchFromCommitMessagePanelToEditor,
|
||||
},
|
||||
)
|
||||
}
|
||||
|
||||
func (self *LocalCommitsController) switchFromCommitMessagePanelToEditor(filepath string) error {
|
||||
if self.isHeadCommit() {
|
||||
return self.c.RunSubprocessAndRefresh(
|
||||
self.c.Git().Commit.RewordLastCommitInEditorWithMessageFileCmdObj(filepath))
|
||||
}
|
||||
|
||||
err := self.c.Git().Rebase.BeginInteractiveRebaseForCommit(self.c.Model().Commits, self.context().GetSelectedLineIdx(), false)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// now the selected commit should be our head so we'll amend it with the new message
|
||||
err = self.c.RunSubprocessAndRefresh(
|
||||
self.c.Git().Commit.RewordLastCommitInEditorWithMessageFileCmdObj(filepath))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
err = self.c.Git().Rebase.ContinueRebase()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return self.c.Refresh(types.RefreshOptions{Mode: types.ASYNC})
|
||||
}
|
||||
|
||||
func (self *LocalCommitsController) handleReword(summary string, description string) error {
|
||||
err := self.c.Git().Rebase.RewordCommit(self.c.Model().Commits, self.c.Contexts().LocalCommits.GetSelectedLineIdx(), summary, description)
|
||||
if err != nil {
|
||||
|
Reference in New Issue
Block a user