Skip to content

Commit 3b7c5a0

Browse files
committed
feat: move switch to editor to commit menu
1 parent 3a923a3 commit 3b7c5a0

File tree

8 files changed

+13
-30
lines changed

8 files changed

+13
-30
lines changed

docs/Config.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -271,8 +271,7 @@ keybinding:
271271
update: 'u'
272272
bulkMenu: 'b'
273273
commitMessage:
274-
switchToEditor: '<c-o>'
275-
commitMenu: '<c-e>'
274+
commitMenu: '<c-o>'
276275
amendAttribute:
277276
addCoAuthor: 'c'
278277
resetAuthor: 'a'

pkg/config/user_config.go

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -440,8 +440,7 @@ type KeybindingSubmodulesConfig struct {
440440
}
441441

442442
type KeybindingCommitMessageConfig struct {
443-
SwitchToEditor string `yaml:"switchToEditor"`
444-
CommitMenu string `yaml:"commitMenu"`
443+
CommitMenu string `yaml:"commitMenu"`
445444
}
446445

447446
// OSConfig contains config on the level of the os
@@ -830,8 +829,7 @@ func GetDefaultConfig() *UserConfig {
830829
BulkMenu: "b",
831830
},
832831
CommitMessage: KeybindingCommitMessageConfig{
833-
SwitchToEditor: "<c-o>",
834-
CommitMenu: "<c-e>",
832+
CommitMenu: "<c-o>",
835833
},
836834
},
837835
OS: OSConfig{},

pkg/gui/context/commit_message_context.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -115,9 +115,8 @@ func (self *CommitMessageContext) SetPanelState(
115115
subtitleTemplate := lo.Ternary(onSwitchToEditor != nil, self.c.Tr.CommitDescriptionSubTitle, self.c.Tr.CommitDescriptionSubTitleNoSwitch)
116116
self.c.Views().CommitDescription.Subtitle = utils.ResolvePlaceholderString(subtitleTemplate,
117117
map[string]string{
118-
"togglePanelKeyBinding": keybindings.Label(self.c.UserConfig.Keybinding.Universal.TogglePanel),
119-
"switchToEditorKeyBinding": keybindings.Label(self.c.UserConfig.Keybinding.CommitMessage.SwitchToEditor),
120-
"commitMenuKeybinding": keybindings.Label(self.c.UserConfig.Keybinding.CommitMessage.CommitMenu),
118+
"togglePanelKeyBinding": keybindings.Label(self.c.UserConfig.Keybinding.Universal.TogglePanel),
119+
"commitMenuKeybinding": keybindings.Label(self.c.UserConfig.Keybinding.CommitMessage.CommitMenu),
121120
})
122121
}
123122

pkg/gui/controllers/commit_description_controller.go

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,6 @@ func (self *CommitDescriptionController) GetKeybindings(opts types.KeybindingsOp
3535
Key: opts.GetKey(opts.Config.Universal.ConfirmInEditor),
3636
Handler: self.confirm,
3737
},
38-
{
39-
Key: opts.GetKey(opts.Config.CommitMessage.SwitchToEditor),
40-
Handler: self.switchToEditor,
41-
},
4238
{
4339
Key: opts.GetKey(opts.Config.CommitMessage.CommitMenu),
4440
Handler: self.openCommitMenu,
@@ -68,10 +64,6 @@ func (self *CommitDescriptionController) confirm() error {
6864
return self.c.Helpers().Commits.HandleCommitConfirm()
6965
}
7066

71-
func (self *CommitDescriptionController) switchToEditor() error {
72-
return self.c.Helpers().Commits.SwitchToEditor()
73-
}
74-
7567
func (self *CommitDescriptionController) openCommitMenu() error {
7668
return self.c.Helpers().Commits.OpenCommitMenu()
7769
}

pkg/gui/controllers/commit_message_controller.go

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -46,10 +46,6 @@ func (self *CommitMessageController) GetKeybindings(opts types.KeybindingsOpts)
4646
Key: opts.GetKey(opts.Config.Universal.TogglePanel),
4747
Handler: self.switchToCommitDescription,
4848
},
49-
{
50-
Key: opts.GetKey(opts.Config.CommitMessage.SwitchToEditor),
51-
Handler: self.switchToEditor,
52-
},
5349
{
5450
Key: opts.GetKey(opts.Config.CommitMessage.CommitMenu),
5551
Handler: self.openCommitMenu,
@@ -92,10 +88,6 @@ func (self *CommitMessageController) switchToCommitDescription() error {
9288
return nil
9389
}
9490

95-
func (self *CommitMessageController) switchToEditor() error {
96-
return self.c.Helpers().Commits.SwitchToEditor()
97-
}
98-
9991
func (self *CommitMessageController) handleCommitIndexChange(value int) error {
10092
currentIndex := self.context().GetSelectedIndex()
10193
newIndex := currentIndex + value

pkg/gui/controllers/helpers/commits_helper.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,13 @@ func (self *CommitsHelper) OpenCommitMenu() error {
201201
},
202202
Key: 'c',
203203
},
204+
{
205+
Label: self.c.Tr.OpenInEditor,
206+
OnPress: func() error {
207+
return self.SwitchToEditor()
208+
},
209+
Key: 'e',
210+
},
204211
}
205212
return self.c.Menu(types.CreateMenuOptions{
206213
Title: self.c.Tr.CommitMenuTitle,

pkg/i18n/english.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1001,7 +1001,7 @@ func EnglishTranslationSet() TranslationSet {
10011001
RebaseOptionsTitle: "Rebase options",
10021002
CommitSummaryTitle: "Commit summary",
10031003
CommitDescriptionTitle: "Commit description",
1004-
CommitDescriptionSubTitle: "{{.togglePanelKeyBinding}} Toggle focus, {{.switchToEditorKeyBinding}} Open editor, {{.commitMenuKeybinding}} Menu",
1004+
CommitDescriptionSubTitle: "Toggle focus {{.togglePanelKeyBinding}}, Open menu {{.commitMenuKeybinding}}",
10051005
CommitDescriptionSubTitleNoSwitch: "Press {{.togglePanelKeyBinding}} to toggle focus",
10061006
LocalBranchesTitle: "Local branches",
10071007
SearchTitle: "Search",

pkg/integration/components/commit_message_panel_driver.go

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -74,10 +74,6 @@ func (self *CommitMessagePanelDriver) Cancel() {
7474
self.getViewDriver().PressEscape()
7575
}
7676

77-
func (self *CommitMessagePanelDriver) SwitchToEditor() {
78-
self.getViewDriver().Press(self.t.keys.CommitMessage.SwitchToEditor)
79-
}
80-
8177
func (self *CommitMessagePanelDriver) SelectPreviousMessage() *CommitMessagePanelDriver {
8278
self.getViewDriver().SelectPreviousItem()
8379
return self

0 commit comments

Comments
 (0)