diff --git a/pkg/gui/global_handlers.go b/pkg/gui/global_handlers.go index a5aabb3610e..62f9311ea2b 100644 --- a/pkg/gui/global_handlers.go +++ b/pkg/gui/global_handlers.go @@ -131,7 +131,7 @@ func (gui *Gui) pageDownConfirmationPanel() error { func (gui *Gui) goToConfirmationPanelTop() error { if gui.Views.Confirmation.Editable { - return nil + return gocui.ErrKeybindingNotHandled } gui.Views.Confirmation.ScrollUp(gui.Views.Confirmation.ViewLinesHeight()) @@ -141,7 +141,7 @@ func (gui *Gui) goToConfirmationPanelTop() error { func (gui *Gui) goToConfirmationPanelBottom() error { if gui.Views.Confirmation.Editable { - return nil + return gocui.ErrKeybindingNotHandled } gui.Views.Confirmation.ScrollDown(gui.Views.Confirmation.ViewLinesHeight()) diff --git a/vendor/github.com/jesseduffield/gocui/gui.go b/vendor/github.com/jesseduffield/gocui/gui.go index 03d55912a3f..375de3ecc7d 100644 --- a/vendor/github.com/jesseduffield/gocui/gui.go +++ b/vendor/github.com/jesseduffield/gocui/gui.go @@ -39,6 +39,9 @@ var ( // ErrQuit is used to decide if the MainLoop finished successfully. ErrQuit = standardErrors.New("quit") + + // ErrKeybindingNotHandled is returned when a keybinding is not handled, so that the key can be dispatched further + ErrKeybindingNotHandled = standardErrors.New("keybinding not handled") ) const ( @@ -1518,7 +1521,13 @@ func (g *Gui) execKeybindings(v *View, ev *GocuiEvent) error { continue } if g.matchView(v, kb) { - return g.execKeybinding(v, kb) + err := g.execKeybinding(v, kb) + if IsKeybindingNotHandled(err) { + matchingParentViewKb = nil + break + } else { + return err + } } if v != nil && g.matchView(v.ParentView, kb) { matchingParentViewKb = kb @@ -1528,7 +1537,10 @@ func (g *Gui) execKeybindings(v *View, ev *GocuiEvent) error { } } if matchingParentViewKb != nil { - return g.execKeybinding(v.ParentView, matchingParentViewKb) + err := g.execKeybinding(v.ParentView, matchingParentViewKb) + if !IsKeybindingNotHandled(err) { + return err + } } if g.currentView != nil && g.currentView.Editable && g.currentView.Editor != nil { @@ -1615,6 +1627,10 @@ func IsQuit(err error) bool { return err != nil && err.Error() == ErrQuit.Error() } +func IsKeybindingNotHandled(err error) bool { + return err != nil && err.Error() == ErrKeybindingNotHandled.Error() +} + func (g *Gui) Suspend() error { g.suspendedMutex.Lock() defer g.suspendedMutex.Unlock()