mirror of
https://github.com/jesseduffield/lazygit.git
synced 2026-06-09 22:05:16 +02:00
8534a05a2e
With more than a couple of pagers, having to cycle forward through all of them to reach the previous one (or to back out of an accidental press of `|`) is tedious. Add a second binding that cycles backward. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
46 lines
1.5 KiB
Go
46 lines
1.5 KiB
Go
package diff
|
|
|
|
import (
|
|
"github.com/jesseduffield/lazygit/pkg/config"
|
|
. "github.com/jesseduffield/lazygit/pkg/integration/components"
|
|
)
|
|
|
|
var CyclePagers = NewIntegrationTest(NewIntegrationTestArgs{
|
|
Description: "Cycle forwards and backwards through configured pagers",
|
|
ExtraCmdArgs: []string{},
|
|
Skip: false,
|
|
SetupConfig: func(cfg *config.AppConfig) {
|
|
cfg.GetUserConfig().Git.Pagers = []config.PagingConfig{
|
|
// an explicit name overrides the derived one
|
|
{Name: "custom name", Pager: "cat"},
|
|
// no name, so it's derived from the first word of the command
|
|
{Pager: "cat -n"},
|
|
// neither name nor command, so it falls back to the default label
|
|
{},
|
|
}
|
|
},
|
|
SetupRepo: func(shell *Shell) {
|
|
shell.CreateNCommits(1)
|
|
},
|
|
Run: func(t *TestDriver, keys config.KeybindingConfig) {
|
|
t.Views().Commits().
|
|
Focus().
|
|
Press(keys.Universal.CyclePagers)
|
|
t.ExpectToast(Equals("Pager: cat (2 of 3)"))
|
|
|
|
t.Views().Commits().Press(keys.Universal.CyclePagers)
|
|
t.ExpectToast(Equals("Pager: (default) (3 of 3)"))
|
|
|
|
// cycling forward past the last pager wraps around to the first
|
|
t.Views().Commits().Press(keys.Universal.CyclePagers)
|
|
t.ExpectToast(Equals("Pager: custom name (1 of 3)"))
|
|
|
|
// cycling backward past the first pager wraps around to the last
|
|
t.Views().Commits().Press(keys.Universal.CyclePagersReverse)
|
|
t.ExpectToast(Equals("Pager: (default) (3 of 3)"))
|
|
|
|
t.Views().Commits().Press(keys.Universal.CyclePagersReverse)
|
|
t.ExpectToast(Equals("Pager: cat (2 of 3)"))
|
|
},
|
|
})
|