mirror of
https://github.com/jesseduffield/lazygit.git
synced 2025-08-08 22:36:49 +02:00
Make conditions easier to understand
This doesn't change behavior, just makes the code a little bit easier to understand: the outermost condition is "do we show a popup and is the mouse event for some other view than the focused one". Only if that's true do we need to define the isCommitMessageView function, and check whether both views belong to the commit message editor.
This commit is contained in:
@ -504,16 +504,17 @@ func (gui *Gui) SetKeybinding(binding *types.Binding) error {
|
|||||||
func (gui *Gui) SetMouseKeybinding(binding *gocui.ViewMouseBinding) error {
|
func (gui *Gui) SetMouseKeybinding(binding *gocui.ViewMouseBinding) error {
|
||||||
baseHandler := binding.Handler
|
baseHandler := binding.Handler
|
||||||
newHandler := func(opts gocui.ViewMouseBindingOpts) error {
|
newHandler := func(opts gocui.ViewMouseBindingOpts) error {
|
||||||
|
if gui.helpers.Confirmation.IsPopupPanelFocused() && gui.currentViewName() != binding.ViewName {
|
||||||
// we ignore click events on views that aren't popup panels, when a popup panel is focused.
|
// we ignore click events on views that aren't popup panels, when a popup panel is focused.
|
||||||
// Unless both the current view and the clicked-on view are either commit message or commit
|
// Unless both the current view and the clicked-on view are either commit message or commit
|
||||||
// description, because we want to allow switching between those two views by clicking.
|
// description, because we want to allow switching between those two views by clicking.
|
||||||
isCommitMessageView := func(viewName string) bool {
|
isCommitMessageView := func(viewName string) bool {
|
||||||
return viewName == "commitMessage" || viewName == "commitDescription"
|
return viewName == "commitMessage" || viewName == "commitDescription"
|
||||||
}
|
}
|
||||||
if gui.helpers.Confirmation.IsPopupPanelFocused() && gui.currentViewName() != binding.ViewName &&
|
if !isCommitMessageView(gui.currentViewName()) || !isCommitMessageView(binding.ViewName) {
|
||||||
(!isCommitMessageView(gui.currentViewName()) || !isCommitMessageView(binding.ViewName)) {
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return baseHandler(opts)
|
return baseHandler(opts)
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user