Files
lazygit/pkg/integration/tests/diff/stat_uses_the_view_width.go
T
Stefan HallerandClaude Opus 5 a51952d826 Lay a diffstat out to the width of the view showing it
Tell a command that renders into a view how wide that view is, through
COLUMNS. git reads it in preference to the size of the terminal it is
talking to, so the diffstat now fills the view whether or not the render
has a terminal to offer.

A diff renderer that can't ask a terminal gets the width from it too;
difftastic, diff-so-fancy and delta all support COLUMNS, so we can stop
running git in a PTY and these will still work.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-09-25 11:31:59 +02:00

43 lines
1.2 KiB
Go

package diff
import (
"strconv"
"strings"
"github.com/jesseduffield/lazygit/pkg/config"
. "github.com/jesseduffield/lazygit/pkg/integration/components"
)
var StatUsesTheViewWidth = NewIntegrationTest(NewIntegrationTestArgs{
Description: "The diffstat of a commit is laid out to the width of the view showing it",
ExtraCmdArgs: []string{},
Skip: false,
SetupConfig: func(cfg *config.AppConfig) {
// git's own diff, so that the render runs as a plain command rather
// than through a renderer.
cfg.GetUserConfig().Git.DiffRenderers = []config.DiffRendererConfig{
{Type: "rawGit"},
}
},
SetupRepo: func(shell *Shell) {
// Enough added lines that git scales the graph to the width it has,
// rather than drawing one mark per line.
lines := make([]string, 200)
for i := range lines {
lines[i] = "line " + strconv.Itoa(i)
}
shell.CreateFileAndAdd("file1", strings.Join(lines, "\n")+"\n")
shell.Commit("add file1")
},
Run: func(t *TestDriver, keys config.KeybindingConfig) {
t.Views().Commits().
Focus().
Lines(
Contains("add file1").IsSelected(),
)
t.Views().Main().
Content(MatchesRegexp(`(?m)^ file1 \| 200 \+{80,}$`))
},
})