Skip to content

Commit ef718f3

Browse files
authored
Show the alt-enter keybinding at bottom of commit description view (#4136)
- **PR Description** It wasn't really obvious how to commit when the focus is in the commit description view, since pressing enter inserts a newline there. To improve this, show the `<a-enter>` keybinding at the bottom of the description view when it is focused. Fixes #4134.
2 parents ebfc7ff + bf93395 commit ef718f3

File tree

3 files changed

+19
-0
lines changed

3 files changed

+19
-0
lines changed

pkg/gui/controllers/commit_description_controller.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@ package controllers
33
import (
44
"github.com/jesseduffield/gocui"
55
"github.com/jesseduffield/lazygit/pkg/gui/context"
6+
"github.com/jesseduffield/lazygit/pkg/gui/keybindings"
67
"github.com/jesseduffield/lazygit/pkg/gui/types"
8+
"github.com/jesseduffield/lazygit/pkg/utils"
79
)
810

911
type CommitDescriptionController struct {
@@ -59,6 +61,15 @@ func (self *CommitDescriptionController) GetMouseKeybindings(opts types.Keybindi
5961
}
6062
}
6163

64+
func (self *CommitDescriptionController) GetOnFocus() func(types.OnFocusOpts) {
65+
return func(types.OnFocusOpts) {
66+
self.c.Views().CommitDescription.Footer = utils.ResolvePlaceholderString(self.c.Tr.CommitDescriptionFooter,
67+
map[string]string{
68+
"confirmInEditorKeybinding": keybindings.Label(self.c.UserConfig().Keybinding.Universal.ConfirmInEditor),
69+
})
70+
}
71+
}
72+
6273
func (self *CommitDescriptionController) switchToCommitMessage() error {
6374
self.c.Context().Replace(self.c.Contexts().CommitMessage)
6475
return nil

pkg/gui/controllers/commit_message_controller.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,12 @@ func (self *CommitMessageController) GetMouseKeybindings(opts types.KeybindingsO
6969
}
7070
}
7171

72+
func (self *CommitMessageController) GetOnFocus() func(types.OnFocusOpts) {
73+
return func(types.OnFocusOpts) {
74+
self.c.Views().CommitDescription.Footer = ""
75+
}
76+
}
77+
7278
func (self *CommitMessageController) GetOnFocusLost() func(types.OnFocusLostOpts) {
7379
return func(types.OnFocusLostOpts) {
7480
self.context().RenderCommitLength()

pkg/i18n/english.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -290,6 +290,7 @@ type TranslationSet struct {
290290
CommitSummaryTitle string
291291
CommitDescriptionTitle string
292292
CommitDescriptionSubTitle string
293+
CommitDescriptionFooter string
293294
LocalBranchesTitle string
294295
SearchTitle string
295296
TagsTitle string
@@ -1290,6 +1291,7 @@ func EnglishTranslationSet() *TranslationSet {
12901291
CommitSummaryTitle: "Commit summary",
12911292
CommitDescriptionTitle: "Commit description",
12921293
CommitDescriptionSubTitle: "Press {{.togglePanelKeyBinding}} to toggle focus, {{.commitMenuKeybinding}} to open menu",
1294+
CommitDescriptionFooter: "Press {{.confirmInEditorKeybinding}} to commit",
12931295
LocalBranchesTitle: "Local branches",
12941296
SearchTitle: "Search",
12951297
TagsTitle: "Tags",

0 commit comments

Comments
 (0)