Files
lazygit/pkg/integration/tests/diff/cycle_diff_renderers.go
T
Stefan Haller 8731d8a51b Rework the custom pager config (rename to diff renderer)
For a long time lazygit has used the term "custom pager" to refer to
what's really a "diff renderer". A pager is a program that allows you to
view output page by page (hence the name), e.g. less; lazygit's custom
diff renderers are not pagers. It used the term only because the feature
is implemented using git's GIT_PAGER env var, but that's an
implementation detail.

Rename the 'git.pagers' config to 'git.diffRenderers', and restructure
its elements while we're at it to make things clearer:

- Add a 'type' field to explicitly specify which type of diff renderer
  it is (the two fundamentally different ones are 'stdinFilter' and
  'extDiff').
- Add a third type, 'rawGit', which has an 'args' field that makes it
  easy to use 'git --color-words' as a custom renderer
- Unify the old 'pager' and 'externalDiffCommand' fields to a single
  'command' field for both types

Existing config files are migrated automatically.
2026-07-31 08:42:51 +02:00

51 lines
1.9 KiB
Go

package diff
import (
"github.com/jesseduffield/lazygit/pkg/config"
. "github.com/jesseduffield/lazygit/pkg/integration/components"
)
var CycleDiffRenderers = NewIntegrationTest(NewIntegrationTestArgs{
Description: "Cycle forwards and backwards through configured diff renderers",
ExtraCmdArgs: []string{},
Skip: false,
SetupConfig: func(cfg *config.AppConfig) {
cfg.GetUserConfig().Git.DiffRenderers = []config.DiffRendererConfig{
// an explicit name overrides the derived one
{Name: "custom name", Command: "cat"},
// no name, so it's derived from the first word of the command
{Command: "cat -n"},
// rawGit derives it from the first argument if any
{Type: "rawGit", Args: []string{"--color-words"}},
// neither name nor command, so it falls back to the default label
{Type: "rawGit"},
}
},
SetupRepo: func(shell *Shell) {
shell.CreateNCommits(1)
},
Run: func(t *TestDriver, keys config.KeybindingConfig) {
t.Views().Commits().
Focus().
Press(keys.Universal.CycleDiffRenderers)
t.ExpectToast(Equals("Diff renderer: cat (2 of 4)"))
t.Views().Commits().Press(keys.Universal.CycleDiffRenderers)
t.ExpectToast(Equals("Diff renderer: --color-words (3 of 4)"))
t.Views().Commits().Press(keys.Universal.CycleDiffRenderers)
t.ExpectToast(Equals("Diff renderer: (default) (4 of 4)"))
// cycling forward past the last diff renderer wraps around to the first
t.Views().Commits().Press(keys.Universal.CycleDiffRenderers)
t.ExpectToast(Equals("Diff renderer: custom name (1 of 4)"))
// cycling backward past the first diff renderer wraps around to the last
t.Views().Commits().Press(keys.Universal.CycleDiffRenderersReverse)
t.ExpectToast(Equals("Diff renderer: (default) (4 of 4)"))
t.Views().Commits().Press(keys.Universal.CycleDiffRenderersReverse)
t.ExpectToast(Equals("Diff renderer: --color-words (3 of 4)"))
},
})