Demonstrate that a diffstat is laid out for 80 columns

git scales the graph of a diffstat to the width of the terminal it is
talking to. A render that talks to no terminal tells it no width, so the
stat comes out narrower than the view it is shown in, wasting most of a
wide one.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
Stefan Haller
2026-09-25 11:31:59 +02:00
co-authored by Claude Opus 5
parent 77c9418c89
commit c217a899ee
2 changed files with 46 additions and 0 deletions
@@ -0,0 +1,45 @@
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().
/* EXPECTED:
Content(MatchesRegexp(`(?m)^ file1 \| 200 \+{80,}$`))
ACTUAL: */
Content(MatchesRegexp(`(?m)^ file1 \| 200 \+{60,70}$`))
},
})
+1
View File
@@ -230,6 +230,7 @@ var tests = []*components.IntegrationTest{
diff.DiffNonStickyRange,
diff.IgnoreWhitespace,
diff.RenameSimilarityThresholdChange,
diff.StatUsesTheViewWidth,
file.ClickArrowToCollapse,
file.CollapseExpand,
file.CopyMenu,