mirror of
https://github.com/jesseduffield/lazygit.git
synced 2025-06-15 00:15:32 +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:
@ -32,6 +32,8 @@ type CommitMessageViewModel struct {
|
||||
preservedMessage string
|
||||
// invoked when pressing enter in the commit message panel
|
||||
onConfirm func(string, string) error
|
||||
// invoked when pressing the switch-to-editor key binding
|
||||
onSwitchToEditor func(string) error
|
||||
|
||||
// The message typed in before cycling through history
|
||||
// We store this separately to 'preservedMessage' because 'preservedMessage'
|
||||
@ -98,10 +100,12 @@ func (self *CommitMessageContext) SetPanelState(
|
||||
descriptionTitle string,
|
||||
preserveMessage bool,
|
||||
onConfirm func(string, string) error,
|
||||
onSwitchToEditor func(string) error,
|
||||
) {
|
||||
self.viewModel.selectedindex = index
|
||||
self.viewModel.preserveMessage = preserveMessage
|
||||
self.viewModel.onConfirm = onConfirm
|
||||
self.viewModel.onSwitchToEditor = onSwitchToEditor
|
||||
self.GetView().Title = summaryTitle
|
||||
self.c.Views().CommitDescription.Title = descriptionTitle
|
||||
}
|
||||
@ -117,3 +121,11 @@ func (self *CommitMessageContext) RenderCommitLength() {
|
||||
func getBufferLength(view *gocui.View) string {
|
||||
return " " + strconv.Itoa(strings.Count(view.TextArea.GetContent(), "")-1) + " "
|
||||
}
|
||||
|
||||
func (self *CommitMessageContext) SwitchToEditor(message string) error {
|
||||
return self.viewModel.onSwitchToEditor(message)
|
||||
}
|
||||
|
||||
func (self *CommitMessageContext) CanSwitchToEditor() bool {
|
||||
return self.viewModel.onSwitchToEditor != nil
|
||||
}
|
||||
|
Reference in New Issue
Block a user