1
0
mirror of https://github.com/jesseduffield/lazygit.git synced 2025-08-09 09:22:48 +03:00

Press enter in focused main view when user config is on

This commit is contained in:
Stefan Haller
2025-04-01 23:03:55 +02:00
parent 2a7578574d
commit e0fdec1c1d
2 changed files with 23 additions and 0 deletions

View File

@@ -30,6 +30,13 @@ func NewMainViewController(
}
func (self *MainViewController) GetKeybindings(opts types.KeybindingsOpts) []*types.Binding {
var goIntoDescription string
// We only want to show the "enter" menu item if the user config is true;
// leaving the description empty causes it to be hidden
if self.c.UserConfig().Gui.ShowSelectionInFocusedMainView {
goIntoDescription = self.c.Tr.EnterStaging
}
return []*types.Binding{
{
Key: opts.GetKey(opts.Config.Universal.TogglePanel),
@@ -43,6 +50,11 @@ func (self *MainViewController) GetKeybindings(opts types.KeybindingsOpts) []*ty
Handler: self.escape,
Description: self.c.Tr.ExitFocusedMainView,
},
{
Key: opts.GetKey(opts.Config.Universal.GoInto),
Handler: self.enter,
Description: goIntoDescription,
},
{
// overriding this because we want to read all of the task's output before we start searching
Key: opts.GetKey(opts.Config.Universal.StartSearch),
@@ -87,6 +99,15 @@ func (self *MainViewController) escape() error {
return nil
}
func (self *MainViewController) enter() error {
parentCtx := self.context.GetParentContext()
if parentCtx.GetOnClickFocusedMainView() != nil {
return parentCtx.GetOnClickFocusedMainView()(
self.context.GetViewName(), self.context.GetView().SelectedLineIdx())
}
return nil
}
func (self *MainViewController) onClickInAlreadyFocusedView(opts gocui.ViewMouseBindingOpts) error {
if self.context.GetView().Highlight && opts.Y != opts.PreviousY {
return nil