summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSean <seand52@gmail.com>2023-01-21 11:38:14 +0000
committerJesse Duffield <jessedduffield@gmail.com>2023-04-30 12:17:34 +1000
commit49da7b482d4f3012814e4100a556ecfad3f0742d (patch)
tree4d403b4301e0918c57ba292b11d6ce9256e8843a
parent826128a8e03fb50f7287029ebac93c85712faecb (diff)
Split commit message panel into commit summary and commit description panel
When we use the one panel for the entire commit message, its tricky to have a keybinding both for adding a newline and submitting. By having two panels: one for the summary line and one for the description, we allow for 'enter' to submit the message when done from the summary panel, and 'enter' to add a newline when done from the description panel. Alt-enter, for those who can use that key combo, also works for submitting the message from the description panel. For those who can't use that key combo, and don't want to remap the keybinding, they can hit tab to go back to the summary panel and then 'enter' to submit the message. We have some awkwardness in that both contexts (i.e. panels) need to appear and disappear in tandem and we don't have a great way of handling that concept, so we just push both contexts one after the other, and likewise remove both contexts when we escape.
-rw-r--r--docs/Config.md1
-rw-r--r--pkg/cheatsheet/generate.go55
-rw-r--r--pkg/commands/git_commands/commit.go41
-rw-r--r--pkg/commands/git_commands/commit_test.go67
-rw-r--r--pkg/config/user_config.go4
-rw-r--r--pkg/gui/commit_message_panel.go1
-rw-r--r--pkg/gui/confirmation_panel.go14
-rw-r--r--pkg/gui/context.go31
-rw-r--r--pkg/gui/context/commit_message_context.go81
-rw-r--r--pkg/gui/context/context.go19
-rw-r--r--pkg/gui/context_config.go22
-rw-r--r--pkg/gui/controllers.go54
-rw-r--r--pkg/gui/controllers/commit_description_controller.go60
-rw-r--r--pkg/gui/controllers/commit_message_controller.go86
-rw-r--r--pkg/gui/controllers/files_controller.go13
-rw-r--r--pkg/gui/controllers/helpers/commits_helper.go163
-rw-r--r--pkg/gui/controllers/helpers/helpers.go2
-rw-r--r--pkg/gui/controllers/helpers/working_tree_helper.go96
-rw-r--r--pkg/gui/controllers/local_commits_controller.go34
-rw-r--r--pkg/gui/editors.go26
-rw-r--r--pkg/gui/files_panel.go4
-rw-r--r--pkg/gui/gui.go4
-rw-r--r--pkg/gui/gui_common.go4
-rw-r--r--pkg/gui/types/common.go4
-rw-r--r--pkg/gui/view_helpers.go35
-rw-r--r--pkg/gui/views.go39
-rw-r--r--pkg/i18n/chinese.go4
-rw-r--r--pkg/i18n/dutch.go4
-rw-r--r--pkg/i18n/english.go12
-rw-r--r--pkg/i18n/japanese.go4
-rw-r--r--pkg/i18n/korean.go4
-rw-r--r--pkg/i18n/polish.go4
-rw-r--r--pkg/integration/components/commit_description_panel_driver.go25
-rw-r--r--pkg/integration/components/commit_message_panel_driver.go33
-rw-r--r--pkg/integration/components/popup.go13
-rw-r--r--pkg/integration/components/view_driver.go5
-rw-r--r--pkg/integration/components/views.go4
-rw-r--r--pkg/integration/tests/commit/commit_multiline.go12
-rw-r--r--pkg/integration/tests/commit/reword.go66
-rw-r--r--pkg/integration/tests/interactive_rebase/reword_first_commit.go4
-rw-r--r--pkg/integration/tests/interactive_rebase/reword_last_commit.go4
-rw-r--r--pkg/integration/tests/interactive_rebase/reword_you_are_here_commit.go4
-rw-r--r--pkg/integration/tests/test_list.go1
43 files changed, 906 insertions, 257 deletions
diff --git a/docs/Config.md b/docs/Config.md
index 92cc9ebd7..837230367 100644
--- a/docs/Config.md
+++ b/docs/Config.md
@@ -171,7 +171,6 @@ keybinding:
diffingMenu-alt: '<c-e>' # deprecated
copyToClipboard: '<c-o>'
submitEditorText: '<enter>'
- appendNewline: '<a-enter>'
extrasMenu: '@'
toggleWhitespaceInDiffView: '<c-w>'
increaseContextInDiffView: '}'
diff --git a/pkg/cheatsheet/generate.go b/pkg/cheatsheet/generate.go
index d68cfbc80..ee2538c1f 100644
--- a/pkg/cheatsheet/generate.go
+++ b/pkg/cheatsheet/generate.go
@@ -87,33 +87,34 @@ func writeString(file *os.File, str string) {
func localisedTitle(tr *i18n.TranslationSet, str string) string {
contextTitleMap := map[string]string{
- "global": tr.GlobalTitle,
- "navigation": tr.NavigationTitle,
- "branches": tr.BranchesTitle,
- "localBranches": tr.LocalBranchesTitle,
- "files": tr.FilesTitle,
- "status": tr.StatusTitle,
- "submodules": tr.SubmodulesTitle,
- "subCommits": tr.SubCommitsTitle,
- "remoteBranches": tr.RemoteBranchesTitle,
- "remotes": tr.RemotesTitle,
- "reflogCommits": tr.ReflogCommitsTitle,
- "tags": tr.TagsTitle,
- "commitFiles": tr.CommitFilesTitle,
- "commitMessage": tr.CommitMessageTitle,
- "commits": tr.CommitsTitle,
- "confirmation": tr.ConfirmationTitle,
- "information": tr.InformationTitle,
- "main": tr.NormalTitle,
- "patchBuilding": tr.PatchBuildingTitle,
- "mergeConflicts": tr.MergingTitle,
- "staging": tr.StagingTitle,
- "menu": tr.MenuTitle,
- "search": tr.SearchTitle,
- "secondary": tr.SecondaryTitle,
- "stash": tr.StashTitle,
- "suggestions": tr.SuggestionsCheatsheetTitle,
- "extras": tr.ExtrasTitle,
+ "global": tr.GlobalTitle,
+ "navigation": tr.NavigationTitle,
+ "branches": tr.BranchesTitle,
+ "localBranches": tr.LocalBranchesTitle,
+ "files": tr.FilesTitle,
+ "status": tr.StatusTitle,
+ "submodules": tr.SubmodulesTitle,
+ "subCommits": tr.SubCommitsTitle,
+ "remoteBranches": tr.RemoteBranchesTitle,
+ "remotes": tr.RemotesTitle,
+ "reflogCommits": tr.ReflogCommitsTitle,
+ "tags": tr.TagsTitle,
+ "commitFiles": tr.CommitFilesTitle,
+ "commitMessage": tr.CommitMessageTitle,
+ "commitDescription": tr.CommitDescriptionTitle,
+ "commits": tr.CommitsTitle,
+ "confirmation": tr.ConfirmationTitle,
+ "information": tr.InformationTitle,
+ "main": tr.NormalTitle,
+ "patchBuilding": tr.PatchBuildingTitle,
+ "mergeConflicts": tr.MergingTitle,
+ "staging": tr.StagingTitle,
+ "menu": tr.MenuTitle,
+ "search": tr.SearchTitle,
+ "secondary": tr.SecondaryTitle,
+ "stash": tr.StashTitle,
+ "suggestions": tr.SuggestionsCheatsheetTitle,
+ "extras": tr.ExtrasTitle,
}
title, ok := contextTitleMap[str]
diff --git a/pkg/commands/git_commands/commit.go b/pkg/commands/git_commands/commit.go
index 38459e351..0c5008e38 100644
--- a/pkg/commands/git_commands/commit.go
+++ b/pkg/commands/git_commands/commit.go
@@ -8,6 +8,8 @@ import (
"github.com/jesseduffield/lazygit/pkg/commands/oscommands"
)
+var ErrInvalidCommitIndex = errors.New("invalid commit index")
+
type CommitCommands struct {
*GitCommon
}
@@ -18,11 +20,6 @@ func NewCommitCommands(gitCommon *GitCommon) *CommitCommands {
}
}
-// RewordLastCommit rewords the topmost commit with the given message
-func (self *CommitCommands) RewordLastCommit(message string) error {
- return self.cmd.New("git commit --allow-empty --amend --only -m " + self.cmd.Quote(message)).Run()
-}
-
// ResetAuthor resets the author of the topmost commit
func (self *CommitCommands) ResetAuthor() error {
return self.cmd.New("git commit --allow-empty --only --no-edit --amend --reset-author").Run()
@@ -45,11 +42,7 @@ func (self *CommitCommands) ResetToCommit(sha string, strength string, envVars [
}
func (self *CommitCommands) CommitCmdObj(message string) oscommands.ICmdObj {
- splitMessage := strings.Split(message, "\n")
- lineArgs := ""
- for _, line := range splitMessage {
- lineArgs += fmt.Sprintf(" -m %s", self.cmd.Quote(line))
- }
+ messageArgs := self.commitMessageArgs(message)
skipHookPrefix := self.UserConfig.Git.SkipHookPrefix
noVerifyFlag := ""
@@ -57,7 +50,23 @@ func (self *CommitCommands) CommitCmdObj(message string) oscommands.ICmdObj {
noVerifyFlag = " --no-verify"
}
- return self.cmd.New(fmt.Sprintf("git commit%s%s%s", noVerifyFlag, self.signoffFlag(), lineArgs))
+ return self.cmd.New(fmt.Sprintf("git commit%s%s%s", noVerifyFlag, self.signoffFlag(), messageArgs))
+}
+
+// RewordLastCommit rewords the topmost commit with the given message
+func (self *CommitCommands) RewordLastCommit(message string) error {
+ messageArgs := self.commitMessageArgs(message)
+ return self.cmd.New(fmt.Sprintf("git commit --allow-empty --amend --only%s", messageArgs)).Run()
+}
+
+func (self *CommitCommands) commitMessageArgs(message string) string {
+ msg, description, _ := strings.Cut(message, "\n")
+ descriptionArgs := ""
+ if description != "" {
+ descriptionArgs = fmt.Sprintf(" -m %s", self.cmd.Quote(description))
+ }
+
+ return fmt.Sprintf(" -m %s%s", self.cmd.Quote(msg), descriptionArgs)
}
// runs git commit without the -m argument meaning it will invoke the user's editor
@@ -178,3 +187,13 @@ func (self *CommitCommands) RevertMerge(sha string, parentNumber int) error {
func (self *CommitCommands) CreateFixupCommit(sha string) error {
return self.cmd.New(fmt.Sprintf("git commit --fixup=%s", sha)).Run()
}
+
+// a value of 0 means the head commit, 1 is the parent commit, etc
+func (self *CommitCommands) GetCommitMessageFromHistory(value int) (string, error) {
+ hash, _ := self.cmd.New(fmt.Sprintf("git log -1 --skip=%d --pretty=%%H", value)).DontLog().RunWithOutput()
+ formattedHash := strings.TrimSpace(hash)
+ if len(formattedHash) == 0 {
+ return "", ErrInvalidCommitIndex
+ }
+ return self.GetCommitMessage(formattedHash)
+}
diff --git a/pkg/commands/git_commands/commit_test.go b/pkg/commands/git_commands/commit_test.go
index 268e44e46..4cc8a8de2 100644
--- a/pkg/commands/git_commands/commit_test.go
+++ b/pkg/commands/git_commands/commit_test.go
@@ -9,12 +9,32 @@ import (
)
func TestCommitRewordCommit(t *testing.T) {
- runner := oscommands.NewFakeRunner(t).
- ExpectGitArgs([]string{"commit", "--allow-empty", "--amend", "--only", "-m", "test"}, "", nil)
- instance := buildCommitCommands(commonDeps{runner: runner})
+ type scenario struct {
+ testName string
+ runner *oscommands.FakeCmdObjRunner
+ input string
+ }
+ scenarios := []scenario{
+ {
+ "Single line reword",
+ oscommands.NewFakeRunner(t).ExpectGitArgs([]string{"commit", "--allow-empty", "--amend", "--only", "-m", "test"}, "", nil),
+ "test",
+ },
+ {
+ "Multi line reword",
+ oscommands.NewFakeRunner(t).ExpectGitArgs([]string{"commit", "--allow-empty", "--amend", "--only", "-m", "test", "-m", "line 2\nline 3"}, "", nil),
+ "test\nline 2\nline 3",
+ },
+ }
+ for _, s := range scenarios {
+ s := s
+ t.Run(s.testName, func(t *testing.T) {
+ instance := buildCommitCommands(commonDeps{runner: s.runner})
- assert.NoError(t, instance.RewordLastCommit("test"))
- runner.CheckForMissingCalls()
+ assert.NoError(t, instance.RewordLastCommit(s.input))
+ s.runner.CheckForMissingCalls()
+ })
+ }
}
func TestCommitResetToCommit(t *testing.T) {
@@ -274,3 +294,40 @@ Merge pull request #1750 from mark2185/fix-issue-template
})
}
}
+
+func TestGetCommitMessageFromHistory(t *testing.T) {
+ type scenario struct {
+ testName string
+ runner *oscommands.FakeCmdObjRunner
+ test func(string, error)
+ }
+ scenarios := []scenario{
+ {
+ "Empty message",
+ oscommands.NewFakeRunner(t).Expect("git log -1 --skip=2 --pretty=%H", "", nil).Expect("git rev-list --format=%B --max-count=1 ", "", nil),
+ func(output string, err error) {
+ assert.Error(t, err)
+ },
+ },
+ {
+ "Default case to retrieve a commit in history",
+ oscommands.NewFakeRunner(t).Expect("git log -1 --skip=2 --pretty=%H", "sha3 \n", nil).Expect("git rev-list --format=%B --max-count=1 sha3", `commit sha3
+ use generics to DRY up context code`, nil),
+ func(output string, err error) {
+ assert.NoError(t, err)
+ assert.Equal(t, "use generics to DRY up context code", output)
+ },
+ },
+ }
+
+ for _, s := range scenarios {
+ s := s
+ t.Run(s.testName, func(t *testing.T) {
+ instance := buildCommitCommands(commonDeps{runner: s.runner})
+
+ output, err := instance.GetCommitMessageFromHistory(2)
+
+ s.test(output, err)
+ })
+ }
+}
diff --git a/pkg/config/user_config.go b/pkg/config/user_config.go
index fb0638e43..fb36bb7ea 100644
--- a/pkg/config/user_config.go
+++ b/pkg/config/user_config.go
@@ -165,6 +165,7 @@ type KeybindingUniversalConfig struct {
Select string `yaml:"select"`
GoInto string `yaml:"goInto"`
Confirm string `yaml:"confirm"`
+ ConfirmInEditor string `yaml:"confirmInEditor"`
Remove string `yaml:"remove"`
New string `yaml:"new"`
Edit string `yaml:"edit"`
@@ -193,7 +194,6 @@ type KeybindingUniversalConfig struct {
CopyToClipboard string `yaml:"copyToClipboard"`
OpenRecentRepos string `yaml:"openRecentRepos"`
SubmitEditorText string `yaml:"submitEditorText"`
- AppendNewline string `yaml:"appendNewline"`
ExtrasMenu string `yaml:"extrasMenu"`
ToggleWhitespaceInDiffView string `yaml:"toggleWhitespaceInDiffView"`
IncreaseContextInDiffView string `yaml:"increaseContextInDiffView"`
@@ -492,6 +492,7 @@ func GetDefaultConfig() *UserConfig {
Select: "<space>",
GoInto: "<enter>",
Confirm: "<enter>",
+ ConfirmInEditor: "<a-enter>",
Remove: "d",
New: "n",
Edit: "e",
@@ -520,7 +521,6 @@ func GetDefaultConfig() *UserConfig {
DiffingMenuAlt: "<c-e>",
CopyToClipboard: "<c-o>",
SubmitEditorText: "<enter>",
- AppendNewline: "<a-enter>",
ExtrasMenu: "@",
ToggleWhitespaceInDiffView: "<c-w>",
IncreaseContextInDiffView: "}",
diff --git a/pkg/gui/commit_message_panel.go b/pkg/gui/commit_message_panel.go
index 4c8ddae2b..051c76573 100644
--- a/pkg/gui/commit_message_panel.go
+++ b/pkg/gui/commit_message_panel.go
@@ -15,7 +15,6 @@ func (gui *Gui) handleCommitMessageFocused() error {
map[string]string{
"keyBindClose": keybindings.Label(gui.c.UserConfig.Keybinding.Universal.Return),
"keyBindConfirm": keybindings.Label(gui.c.UserConfig.Keybinding.Universal.Confirm),
- "keyBindNewLine": keybindings.Label(gui.c.UserConfig.Keybinding.Universal.AppendNewline),
},
)
diff --git a/pkg/gui/confirmation_panel.go b/pkg/gui/confirmation_panel.go
index c3e50c2a1..bcdec70d1 100644
--- a/pkg/gui/confirmation_panel.go
+++ b/pkg/gui/confirmation_panel.go
@@ -78,17 +78,11 @@ func (gui *Gui) getMessageHeight(wrap bool, message string, width int) int {
return lineCount
}
-func (gui *Gui) getConfirmationPanelDimensions(wrap bool, prompt string) (int, int, int, int) {
- panelWidth := gui.getConfirmationPanelWidth()
- panelHeight := gui.getMessageHeight(wrap, prompt, panelWidth)
- return gui.getConfirmationPanelDimensionsAux(panelWidth, panelHeight)
+func (gui *Gui) getPopupPanelDimensionsForContentHeight(panelWidth, contentHeight int) (int, int, int, int) {
+ return gui.getPopupPanelDimensionsAux(panelWidth, contentHeight)
}
-func (gui *Gui) getConfirmationPanelDimensionsForContentHeight(panelWidth, contentHeight int) (int, int, int, int) {
- return gui.getConfirmationPanelDimensionsAux(panelWidth, contentHeight)
-}
-
-func (gui *Gui) getConfirmationPanelDimensionsAux(panelWidth int, panelHeight int) (int, int, int, int) {
+func (gui *Gui) getPopupPanelDimensionsAux(panelWidth int, panelHeight int) (int, int, int, int) {
width, height := gui.g.Size()
if panelHeight > height*3/4 {
panelHeight = height * 3 / 4
@@ -186,7 +180,7 @@ func (gui *Gui) createPopupPanel(ctx context.Context, opts types.CreatePopupPane
}
confirmationView := gui.Views.Confirmation
confirmationView.Editable = opts.Editable
- confirmationView.Editor = gocui.EditorFunc(gui.defaultEditor)
+ confirmationView.Editor = gocui.EditorFunc(gui.promptEditor)
if opts.Editable {
textArea := confirmationView.TextArea
diff --git a/pkg/gui/context.go b/pkg/gui/context.go
index f097df807..d69b245ff 100644
--- a/pkg/gui/context.go
+++ b/pkg/gui/context.go
@@ -9,6 +9,7 @@ import (
"github.com/jesseduffield/gocui"
"github.com/jesseduffield/lazygit/pkg/gui/context"
"github.com/jesseduffield/lazygit/pkg/gui/types"
+ "github.com/samber/lo"
)
// This file is for the management of contexts. There is a context stack such that
@@ -146,6 +147,36 @@ func (gui *Gui) popContext() error {
return gui.activateContext(newContext, types.OnFocusOpts{})
}
+func (gui *Gui) removeContexts(contextsToRemove []types.Context) error {
+ gui.State.ContextManager.Lock()
+
+ if len(gui.State.ContextManager.ContextStack) == 1 {
+ gui.State.ContextManager.Unlock()
+ return nil
+ }
+
+ rest := lo.Filter(gui.State.ContextManager.ContextStack, func(context types.Context, _ int) bool {
+ for _, contextToRemove := range contextsToRemove {
+ if context.GetKey() == contextToRemove.GetKey() {
+ return false
+ }
+ }
+ return true
+ })
+ gui.State.ContextManager.ContextStack = rest
+ contextToActivate := rest[len(rest)-1]
+ gui.State.ContextManager.Unlock()
+
+ for _, context := range contextsToRemove {
+ if err := gui.deactivateContext(context, types.OnFocusLostOpts{NewContextKey: contextToActivate.GetKey()}); err != nil {
+ return err
+ }
+ }
+
+ // activate the item at the top of the stack
+ return gui.activateContext(contextToActivate, types.OnFocusOpts{})
+}
+
func (gui *Gui) deactivateContext(c types.Context, opts types.OnFocusLostOpts) error {
view, _ := gui.g.View(c.GetViewName())
diff --git a/pkg/gui/context/commit_message_context.go b/pkg/gui/context/commit_message_context.go
new file mode 100644
index 000000000..a660ca23a
--- /dev/null
+++ b/pkg/gui/context/commit_message_context.go
@@ -0,0 +1,81 @@
+package context
+
+import (
+ "github.com/jesseduffield/gocui"
+ "github.com/jesseduffield/lazygit/pkg/gui/types"
+)
+
+type CommitMessageContext struct {
+ types.Context
+ viewModel *CommitMessageViewModel
+}
+
+// when selectedIndex (see below) is set to this value, it means that we're not
+// currently viewing a commit message of an existing commit: instead we're making our own
+// new commit message
+const NoCommitIndex = -1
+
+type CommitMessageViewModel struct {
+ // index of the commit message, where -1 is 'no commit', 0 is the HEAD commit, 1
+ // is the prior commit, and so on
+ selectedindex int
+ // if true, then upon escaping from the commit message panel, we will preserve
+ // the message so that it's still shown next time we open the panel
+ preserveMessage bool
+ // the full preserved message (combined summary and description)
+ preservedMessage string
+ // invoked when pressing enter in the commit message panel
+ onConfirm func(string) error
+}
+
+func NewCommitMessageContext(
+ view *gocui.View,
+ opts ContextCallbackOpts,
+) *CommitMessageContext {
+ viewModel := &CommitMessageViewModel{}
+ return &CommitMessageContext{
+ viewModel: viewModel,
+ Context: NewSimpleContext(
+ NewBaseContext(NewBaseContextOpts{
+ Kind: types.PERSISTENT_POPUP,
+ View: view,
+ WindowName: "commitMessage",
+ Key: COMMIT_MESSAGE_CONTEXT_KEY,
+ Focusable: true,
+ HasUncontrolledBounds: true,
+ }),
+ opts,
+ ),
+ }
+}
+
+func (self *CommitMessageContext) SetSelectedIndex(value int) {
+ self.viewModel.selectedindex = value
+}
+
+func (self *CommitMessageContext) GetSelectedIndex() int {
+ return self.viewModel.selectedindex
+}
+
+func (self *CommitMessageContext) GetPreserveMessage() bool {
+ return self.viewModel.preserveMessage
+}
+
+func (self *CommitMessageContext) OnConfirm(message string) error {
+ return self.viewModel.onConfirm(message)
+}
+
+func (self *CommitMessageContext) SetPanelState(index int, title string, preserveMessage bool, onConfirm func(string) error) {
+ self.viewModel.selectedindex = index
+ self.viewModel.preserveMessage = preserveMessage
+ self.viewModel.onConfirm = onConfirm
+ self.GetView().Title = title
+}
+
+func (self *CommitMessageContext) SetPreservedMessage(message string) {
+ self.viewModel.preservedMessage = message
+}
+
+func (self *CommitMessageContext) GetPreservedMessage() string {
+ return self.viewModel.preservedMessage
+}
diff --git a/pkg/gui/context/context.go b/pkg/gui/context/context.go
index 5a88b4a26..7fc0d52f6 100644
--- a/pkg/gui/context/context.go
+++ b/pkg/gui/context/context.go
@@ -33,13 +33,14 @@ const (
INFORMATION_CONTEXT_KEY types.ContextKey = "information"
LIMIT_CONTEXT_KEY types.ContextKey = "limit"
- MENU_CONTEXT_KEY types.ContextKey = "menu"
- CONFIRMATION_CONTEXT_KEY types.ContextKey = "confirmation"
- SEARCH_CONTEXT_KEY types.ContextKey = "search"
- COMMIT_MESSAGE_CONTEXT_KEY types.ContextKey = "commitMessage"
- SUBMODULES_CONTEXT_KEY types.ContextKey = "submodules"
- SUGGESTIONS_CONTEXT_KEY types.ContextKey = "suggestions"
- COMMAND_LOG_CONTEXT_KEY types.ContextKey = "cmdLog"
+ MENU_CONTEXT_KEY types.ContextKey = "menu"
+ CONFIRMATION_CONTEXT_KEY types.ContextKey = "confirmation"
+ SEARCH_CONTEXT_KEY types.ContextKey = "search"
+ COMMIT_MESSAGE_CONTEXT_KEY types.ContextKey = "commitMessage"
+ COMMIT_DESCRIPTION_CONTEXT_KEY types.ContextKey = "commitDescription"
+ SUBMODULES_CONTEXT_KEY types.ContextKey = "submodules"
+ SUGGESTIONS_CONTEXT_KEY types.ContextKey = "suggestions"
+ COMMAND_LOG_CONTEXT_KEY types.ContextKey = "cmdLog"
)
var AllContextKeys = []types.ContextKey{
@@ -97,7 +98,8 @@ type ContextTree struct {
CustomPatchBuilderSecondary types.Context
MergeConflicts *MergeConflictsContext
Confirmation types.Context
- CommitMessage types.Context
+ CommitMessage *CommitMessageContext
+ CommitDescription types.Context
CommandLog types.Context
// display contexts
@@ -129,6 +131,7 @@ func (self *ContextTree) Flatten() []types.Context {
self.Menu,
self.Confirmation,
self.CommitMessage,
+ self.CommitDescription,
self.MergeConflicts,
self.StagingSecondary,
diff --git a/pkg/gui/context_config.go b/pkg/gui/context_config.go
index b19824237..aa056f5c5 100644
--- a/pkg/gui/context_config.go
+++ b/pkg/gui/context_config.go
@@ -217,17 +217,29 @@ func (gui *Gui) contextTree() *context.ContextTree {
},
},
),
- CommitMessage: context.NewSimpleContext(
+ CommitMessage: context.NewCommitMessageContext(
+ gui.Views.CommitMessage,
+ context.ContextCallbackOpts{
+ OnFocus: OnFocusWrapper(gui.handleCommitMessageFocused),
+ },
+ ),
+ CommitDescription: context.NewSimpleContext(
context.NewBaseContext(context.NewBaseContextOpts{
Kind: types.PERSISTENT_POPUP,
- View: gui.Views.CommitMessage,
- WindowName: "commitMessage",
- Key: context.COMMIT_MESSAGE_CONTEXT_KEY,
+ View: gui.Views.CommitDescription,
+ WindowName: "commitDescription",
+ Key: context.COMMIT_DESCRIPTION_CONTEXT_KEY,
Focusable: true,
HasUncontrolledBounds: true,
}),
context.ContextCallbackOpts{
- OnFocus: OnFocusWrapper(gui.handleCommitMessageFocused),
+ OnFocus: func(opts types.OnFocusOpts) error {
+ _, err := gui.g.SetViewBeneath("commitDescription", "commitMessage", 10)
+ if err != nil {
+ return err
+ }
+ return nil
+ },
},
),
Search: context.NewSimpleContext(
diff --git a/pkg/gui/controllers.go b/pkg/gui/controllers.go
index b8fba8c85..4b13eaa20 100644
--- a/pkg/gui/controllers.go
+++ b/pkg/gui/controllers.go
@@ -9,7 +9,6 @@ import (
"github.com/jesseduffield/lazygit/pkg/gui/controllers/helpers"
"github.com/jesseduffield/lazygit/pkg/gui/modes/cherrypicking"
"github.com/jesseduffield/lazygit/pkg/gui/services/custom_commands"
- "github.com/jesseduffield/lazygit/pkg/gui/types"
"github.com/jesseduffield/lazygit/pkg/snake"
)
@@ -26,10 +25,24 @@ func (gui *Gui) resetControllers() {
rebaseHelper := helpers.NewMergeAndRebaseHelper(helperCommon, gui.State.Contexts, gui.git, refsHelper)
suggestionsHelper := helpers.NewSuggestio