Skip to content

Commit 2e5cf46

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

File tree

1 file changed

+10
-9
lines changed

1 file changed

+10
-9
lines changed

pkg/gui/keybindings.go

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -504,15 +504,16 @@ func (gui *Gui) SetKeybinding(binding *types.Binding) error {
504504
func (gui *Gui) SetMouseKeybinding(binding *gocui.ViewMouseBinding) error {
505505
baseHandler := binding.Handler
506506
newHandler := func(opts gocui.ViewMouseBindingOpts) error {
507-
// we ignore click events on views that aren't popup panels, when a popup panel is focused.
508-
// Unless both the current view and the clicked-on view are either commit message or commit
509-
// description, because we want to allow switching between those two views by clicking.
510-
isCommitMessageView := func(viewName string) bool {
511-
return viewName == "commitMessage" || viewName == "commitDescription"
512-
}
513-
if gui.helpers.Confirmation.IsPopupPanelFocused() && gui.currentViewName() != binding.ViewName &&
514-
(!isCommitMessageView(gui.currentViewName()) || !isCommitMessageView(binding.ViewName)) {
515-
return nil
507+
if gui.helpers.Confirmation.IsPopupPanelFocused() && gui.currentViewName() != binding.ViewName {
508+
// we ignore click events on views that aren't popup panels, when a popup panel is focused.
509+
// Unless both the current view and the clicked-on view are either commit message or commit
510+
// description, because we want to allow switching between those two views by clicking.
511+
isCommitMessageView := func(viewName string) bool {
512+
return viewName == "commitMessage" || viewName == "commitDescription"
513+
}
514+
if !isCommitMessageView(gui.currentViewName()) || !isCommitMessageView(binding.ViewName) {
515+
return nil
516+
}
516517
}
517518

518519
return baseHandler(opts)

0 commit comments

Comments
 (0)