1
0
mirror of https://github.com/jesseduffield/lazygit.git synced 2025-07-28 16:02:01 +03:00

Allow clicking in focused main view to go to staging

Only works if a file is selected.
This commit is contained in:
Stefan Haller
2025-03-26 12:39:39 +01:00
parent 755b90b2e4
commit 8eb35e2c25
7 changed files with 70 additions and 9 deletions

View File

@ -323,6 +323,16 @@ func (self *FilesController) GetOnClick() func() error {
})
}
func (self *FilesController) GetOnClickFocusedMainView() func(mainViewName string, clickedLineIdx int) error {
return func(mainViewName string, clickedLineIdx int) error {
node := self.getSelectedItem()
if node != nil && node.File != nil {
return self.EnterFile(types.OnFocusOpts{ClickedWindowName: mainViewName, ClickedViewLineIdx: clickedLineIdx})
}
return nil
}
}
// if we are dealing with a status for which there is no key in this map,
// then we won't optimistically render: we'll just let `git status` tell
// us what the new status is.
@ -545,7 +555,8 @@ func (self *FilesController) EnterFile(opts types.OnFocusOpts) error {
return self.handleNonInlineConflict(file)
}
self.c.Context().Push(self.c.Contexts().Staging, opts)
context := lo.Ternary(opts.ClickedWindowName == "secondary", self.c.Contexts().StagingSecondary, self.c.Contexts().Staging)
self.c.Context().Push(context, opts)
return nil
}