Skip to content

Commit f6c20f2

Browse files
committed
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.
1 parent 2e5cf46 commit f6c20f2

File tree

2 files changed

+10
-17
lines changed

2 files changed

+10
-17
lines changed

pkg/gui/controllers/commit_description_controller.go

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ package controllers
22

33
import (
44
"github.com/jesseduffield/gocui"
5-
"github.com/jesseduffield/lazygit/pkg/gui/context"
65
"github.com/jesseduffield/lazygit/pkg/gui/keybindings"
76
"github.com/jesseduffield/lazygit/pkg/gui/types"
87
"github.com/jesseduffield/lazygit/pkg/utils"
@@ -58,9 +57,10 @@ func (self *CommitDescriptionController) Context() types.Context {
5857
func (self *CommitDescriptionController) GetMouseKeybindings(opts types.KeybindingsOpts) []*gocui.ViewMouseBinding {
5958
return []*gocui.ViewMouseBinding{
6059
{
61-
ViewName: self.Context().GetViewName(),
62-
Key: gocui.MouseLeft,
63-
Handler: self.onClick,
60+
ViewName: self.Context().GetViewName(),
61+
FocusedView: self.c.Contexts().CommitMessage.GetViewName(),
62+
Key: gocui.MouseLeft,
63+
Handler: self.onClick,
6464
},
6565
}
6666
}
@@ -137,10 +137,6 @@ func (self *CommitDescriptionController) openCommitMenu() error {
137137
}
138138

139139
func (self *CommitDescriptionController) onClick(opts gocui.ViewMouseBindingOpts) error {
140-
// Activate the description panel when the commit message panel is currently active
141-
if self.c.Context().Current().GetKey() == context.COMMIT_MESSAGE_CONTEXT_KEY {
142-
self.c.Context().Replace(self.c.Contexts().CommitDescription)
143-
}
144-
140+
self.c.Context().Replace(self.c.Contexts().CommitDescription)
145141
return nil
146142
}

pkg/gui/controllers/commit_message_controller.go

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -62,9 +62,10 @@ func (self *CommitMessageController) GetKeybindings(opts types.KeybindingsOpts)
6262
func (self *CommitMessageController) GetMouseKeybindings(opts types.KeybindingsOpts) []*gocui.ViewMouseBinding {
6363
return []*gocui.ViewMouseBinding{
6464
{
65-
ViewName: self.Context().GetViewName(),
66-
Key: gocui.MouseLeft,
67-
Handler: self.onClick,
65+
ViewName: self.Context().GetViewName(),
66+
FocusedView: self.c.Contexts().CommitDescription.GetViewName(),
67+
Key: gocui.MouseLeft,
68+
Handler: self.onClick,
6869
},
6970
}
7071
}
@@ -194,10 +195,6 @@ func (self *CommitMessageController) openCommitMenu() error {
194195
}
195196

196197
func (self *CommitMessageController) onClick(opts gocui.ViewMouseBindingOpts) error {
197-
// Activate the commit message panel when the commit description panel is currently active
198-
if self.c.Context().Current().GetKey() == context.COMMIT_DESCRIPTION_CONTEXT_KEY {
199-
self.c.Context().Replace(self.c.Contexts().CommitMessage)
200-
}
201-
198+
self.c.Context().Replace(self.c.Contexts().CommitMessage)
202199
return nil
203200
}

0 commit comments

Comments
 (0)