mirror of
https://github.com/jesseduffield/lazygit.git
synced 2026-09-11 16:16:28 -04:00
Modifiers were moved into Key in 22169e22f, but the separate Modifier field
on types.Binding and gocui.keybinding was left behind. The keypress matcher
already compares modifiers via Key.Equals, so the old field is never read on
the dispatch path; it just got passed through SetKeybinding and stored.
Drop it from gocui.keybinding, types.Binding, and the SetKeybinding /
DeleteKeybinding signatures, and remove every now-redundant Modifier:
gocui.ModNone struct field. Mouse bindings keep their own Modifier (on
ViewMouseBinding) since that path still consults it.
61 lines
1.6 KiB
Go
61 lines
1.6 KiB
Go
package controllers
|
|
|
|
import (
|
|
"log"
|
|
|
|
"github.com/jesseduffield/lazygit/pkg/gui/types"
|
|
"github.com/samber/lo"
|
|
)
|
|
|
|
type JumpToSideWindowController struct {
|
|
baseController
|
|
c *ControllerCommon
|
|
nextTabFunc func() error
|
|
}
|
|
|
|
func NewJumpToSideWindowController(
|
|
c *ControllerCommon,
|
|
nextTabFunc func() error,
|
|
) *JumpToSideWindowController {
|
|
return &JumpToSideWindowController{
|
|
baseController: baseController{},
|
|
c: c,
|
|
nextTabFunc: nextTabFunc,
|
|
}
|
|
}
|
|
|
|
func (self *JumpToSideWindowController) Context() types.Context {
|
|
return nil
|
|
}
|
|
|
|
func (self *JumpToSideWindowController) GetKeybindings(opts types.KeybindingsOpts) []*types.Binding {
|
|
windows := self.c.Helpers().Window.SideWindows()
|
|
|
|
if len(opts.Config.Universal.JumpToBlock) != len(windows) {
|
|
log.Fatal("Jump to block keybindings cannot be set. Exactly 5 keybindings must be supplied.")
|
|
}
|
|
|
|
return lo.Map(windows, func(window string, index int) *types.Binding {
|
|
return &types.Binding{
|
|
ViewName: "",
|
|
// by default the keys are 1, 2, 3, etc
|
|
Key: opts.GetKey(opts.Config.Universal.JumpToBlock[index]),
|
|
Handler: opts.Guards.NoPopupPanel(self.goToSideWindow(window)),
|
|
}
|
|
})
|
|
}
|
|
|
|
func (self *JumpToSideWindowController) goToSideWindow(window string) func() error {
|
|
return func() error {
|
|
sideWindowAlreadyActive := self.c.Helpers().Window.CurrentWindow() == window
|
|
if sideWindowAlreadyActive && self.c.UserConfig().Gui.SwitchTabsWithPanelJumpKeys {
|
|
return self.nextTabFunc()
|
|
}
|
|
|
|
context := self.c.Helpers().Window.GetContextForWindow(window)
|
|
|
|
self.c.Context().Push(context, types.OnFocusOpts{})
|
|
return nil
|
|
}
|
|
}
|