1
0
mirror of https://github.com/jesseduffield/lazygit.git synced 2025-08-09 09:22:48 +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 acfa024915
commit fbb8b2e17e
7 changed files with 70 additions and 9 deletions

View File

@@ -1,6 +1,7 @@
package controllers
import (
"github.com/jesseduffield/gocui"
"github.com/jesseduffield/lazygit/pkg/gui/context"
"github.com/jesseduffield/lazygit/pkg/gui/types"
)
@@ -52,6 +53,16 @@ func (self *MainViewController) GetKeybindings(opts types.KeybindingsOpts) []*ty
}
}
func (self *MainViewController) GetMouseKeybindings(opts types.KeybindingsOpts) []*gocui.ViewMouseBinding {
return []*gocui.ViewMouseBinding{
{
ViewName: self.context.GetViewName(),
Key: gocui.MouseLeft,
Handler: self.onClick,
},
}
}
func (self *MainViewController) Context() types.Context {
return self.context
}
@@ -70,6 +81,14 @@ func (self *MainViewController) escape() error {
return nil
}
func (self *MainViewController) onClick(opts gocui.ViewMouseBindingOpts) error {
parentCtx := self.context.GetParentContext()
if parentCtx.GetOnClickFocusedMainView() != nil {
return parentCtx.GetOnClickFocusedMainView()(self.context.GetViewName(), opts.Y)
}
return nil
}
func (self *MainViewController) openSearch() error {
if manager := self.c.GetViewBufferManagerForView(self.context.GetView()); manager != nil {
manager.ReadToEnd(func() {