mirror of
https://github.com/jesseduffield/lazygit.git
synced 2025-07-17 01:42:45 +02:00
Switch tabs with panel jump keys (#3794)
- **PR Description** When using the panel jump keybindings (`1` through `5` by default), and the target panel is already the active one, go to the next tab instead.
This commit is contained in:
@ -197,7 +197,7 @@ func (gui *Gui) resetHelpersAndControllers() {
|
|||||||
commandLogController := controllers.NewCommandLogController(common)
|
commandLogController := controllers.NewCommandLogController(common)
|
||||||
confirmationController := controllers.NewConfirmationController(common)
|
confirmationController := controllers.NewConfirmationController(common)
|
||||||
suggestionsController := controllers.NewSuggestionsController(common)
|
suggestionsController := controllers.NewSuggestionsController(common)
|
||||||
jumpToSideWindowController := controllers.NewJumpToSideWindowController(common)
|
jumpToSideWindowController := controllers.NewJumpToSideWindowController(common, gui.handleNextTab)
|
||||||
|
|
||||||
sideWindowControllerFactory := controllers.NewSideWindowControllerFactory(common)
|
sideWindowControllerFactory := controllers.NewSideWindowControllerFactory(common)
|
||||||
|
|
||||||
|
@ -10,15 +10,18 @@ import (
|
|||||||
|
|
||||||
type JumpToSideWindowController struct {
|
type JumpToSideWindowController struct {
|
||||||
baseController
|
baseController
|
||||||
c *ControllerCommon
|
c *ControllerCommon
|
||||||
|
nextTabFunc func() error
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewJumpToSideWindowController(
|
func NewJumpToSideWindowController(
|
||||||
c *ControllerCommon,
|
c *ControllerCommon,
|
||||||
|
nextTabFunc func() error,
|
||||||
) *JumpToSideWindowController {
|
) *JumpToSideWindowController {
|
||||||
return &JumpToSideWindowController{
|
return &JumpToSideWindowController{
|
||||||
baseController: baseController{},
|
baseController: baseController{},
|
||||||
c: c,
|
c: c,
|
||||||
|
nextTabFunc: nextTabFunc,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -46,6 +49,10 @@ func (self *JumpToSideWindowController) GetKeybindings(opts types.KeybindingsOpt
|
|||||||
|
|
||||||
func (self *JumpToSideWindowController) goToSideWindow(window string) func() error {
|
func (self *JumpToSideWindowController) goToSideWindow(window string) func() error {
|
||||||
return func() error {
|
return func() error {
|
||||||
|
if self.c.Helpers().Window.CurrentWindow() == window {
|
||||||
|
return self.nextTabFunc()
|
||||||
|
}
|
||||||
|
|
||||||
context := self.c.Helpers().Window.GetContextForWindow(window)
|
context := self.c.Helpers().Window.GetContextForWindow(window)
|
||||||
|
|
||||||
return self.c.PushContext(context)
|
return self.c.PushContext(context)
|
||||||
|
@ -338,6 +338,7 @@ var tests = []*components.IntegrationTest{
|
|||||||
ui.OpenLinkFailure,
|
ui.OpenLinkFailure,
|
||||||
ui.RangeSelect,
|
ui.RangeSelect,
|
||||||
ui.SwitchTabFromMenu,
|
ui.SwitchTabFromMenu,
|
||||||
|
ui.SwitchTabWithPanelJumpKeys,
|
||||||
undo.UndoCheckoutAndDrop,
|
undo.UndoCheckoutAndDrop,
|
||||||
undo.UndoDrop,
|
undo.UndoDrop,
|
||||||
worktree.AddFromBranch,
|
worktree.AddFromBranch,
|
||||||
|
34
pkg/integration/tests/ui/switch_tab_with_panel_jump_keys.go
Normal file
34
pkg/integration/tests/ui/switch_tab_with_panel_jump_keys.go
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
package ui
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/jesseduffield/lazygit/pkg/config"
|
||||||
|
. "github.com/jesseduffield/lazygit/pkg/integration/components"
|
||||||
|
)
|
||||||
|
|
||||||
|
var SwitchTabWithPanelJumpKeys = NewIntegrationTest(NewIntegrationTestArgs{
|
||||||
|
Description: "Switch tab with the panel jump keys",
|
||||||
|
ExtraCmdArgs: []string{},
|
||||||
|
Skip: false,
|
||||||
|
SetupConfig: func(config *config.AppConfig) {},
|
||||||
|
SetupRepo: func(shell *Shell) {
|
||||||
|
},
|
||||||
|
Run: func(t *TestDriver, keys config.KeybindingConfig) {
|
||||||
|
t.Views().Worktrees().Focus().
|
||||||
|
Press(keys.Universal.JumpToBlock[2])
|
||||||
|
|
||||||
|
t.Views().Branches().IsFocused().
|
||||||
|
Press(keys.Universal.JumpToBlock[2])
|
||||||
|
|
||||||
|
t.Views().Remotes().IsFocused().
|
||||||
|
Press(keys.Universal.JumpToBlock[2])
|
||||||
|
|
||||||
|
t.Views().Tags().IsFocused().
|
||||||
|
Press(keys.Universal.JumpToBlock[2])
|
||||||
|
|
||||||
|
t.Views().Branches().IsFocused().
|
||||||
|
Press(keys.Universal.JumpToBlock[1])
|
||||||
|
|
||||||
|
// When jumping to a panel from a different one, keep its current tab:
|
||||||
|
t.Views().Worktrees().IsFocused()
|
||||||
|
},
|
||||||
|
})
|
Reference in New Issue
Block a user