1
0
mirror of https://github.com/jesseduffield/lazygit.git synced 2025-08-06 22:33:07 +02:00

Cleanup: use FocusedView property for mouse bindings

This way the click is only handled if a given view has the focus, and we don't
have to check this manually in the handler.
This commit is contained in:
Stefan Haller
2025-07-10 17:46:43 +02:00
parent 2e5cf46716
commit f6c20f2745
2 changed files with 10 additions and 17 deletions

View File

@ -2,7 +2,6 @@ package controllers
import (
"github.com/jesseduffield/gocui"
"github.com/jesseduffield/lazygit/pkg/gui/context"
"github.com/jesseduffield/lazygit/pkg/gui/keybindings"
"github.com/jesseduffield/lazygit/pkg/gui/types"
"github.com/jesseduffield/lazygit/pkg/utils"
@ -59,6 +58,7 @@ func (self *CommitDescriptionController) GetMouseKeybindings(opts types.Keybindi
return []*gocui.ViewMouseBinding{
{
ViewName: self.Context().GetViewName(),
FocusedView: self.c.Contexts().CommitMessage.GetViewName(),
Key: gocui.MouseLeft,
Handler: self.onClick,
},
@ -137,10 +137,6 @@ func (self *CommitDescriptionController) openCommitMenu() error {
}
func (self *CommitDescriptionController) onClick(opts gocui.ViewMouseBindingOpts) error {
// Activate the description panel when the commit message panel is currently active
if self.c.Context().Current().GetKey() == context.COMMIT_MESSAGE_CONTEXT_KEY {
self.c.Context().Replace(self.c.Contexts().CommitDescription)
}
return nil
}

View File

@ -63,6 +63,7 @@ func (self *CommitMessageController) GetMouseKeybindings(opts types.KeybindingsO
return []*gocui.ViewMouseBinding{
{
ViewName: self.Context().GetViewName(),
FocusedView: self.c.Contexts().CommitDescription.GetViewName(),
Key: gocui.MouseLeft,
Handler: self.onClick,
},
@ -194,10 +195,6 @@ func (self *CommitMessageController) openCommitMenu() error {
}
func (self *CommitMessageController) onClick(opts gocui.ViewMouseBindingOpts) error {
// Activate the commit message panel when the commit description panel is currently active
if self.c.Context().Current().GetKey() == context.COMMIT_DESCRIPTION_CONTEXT_KEY {
self.c.Context().Replace(self.c.Contexts().CommitMessage)
}
return nil
}