Let wrapLinesInDiffView govern the two main panes

Working in a diff used to mean the staging view, and this option said
whether the long lines there were wrapped. The main view does that work
now, and the option has had nothing to govern since the staging view went
away. Both panes wrap whatever they are given.

Make the option their wrap setting instead.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
Stefan Haller
2026-09-27 18:26:56 +02:00
co-authored by Claude Opus 5
parent a15a80bdd6
commit 5da90439ee
4 changed files with 79 additions and 0 deletions
+4
View File
@@ -70,6 +70,10 @@ func (gui *Gui) RefreshMainView(opts *types.ViewUpdateOpts, context types.Contex
if mainContext := gui.mainContextForView(view); mainContext != nil {
mainContext.SetContentIsDiff(types.ContentIsDiff(opts.Task))
// A diff is wrapped as the user asks; anything else a main pane shows is prose
// or a log, and reads as badly cut off at the edge of the pane as it would
// anywhere else.
view.Wrap = !mainContext.ContentIsDiff() || gui.c.UserConfig().Gui.WrapLinesInDiffView
}
if err := gui.runTaskForView(view, opts.Task); err != nil {
+32
View File
@@ -217,6 +217,38 @@ func (self *ViewDriver) ContainsLines(matchers ...*TextMatcher) *ViewDriver {
return self
}
// asserts that somewhere in the view there are consecutive lines matching the given
// matchers, taking the lines as the view lays them out rather than as its content has
// them: a line of content too long for a view that wraps is several of these.
func (self *ViewDriver) ContainsViewLines(matchers ...*TextMatcher) *ViewDriver {
self.validateMatchersPassed(matchers)
self.t.assertWithRetries(func() (bool, string) {
lines := self.getView().ViewBufferLines()
for i := range len(lines) - len(matchers) + 1 {
matches := true
for j, matcher := range matchers {
if ok, _ := matcher.test(lines[i+j]); !ok {
matches = false
break
}
}
if matches {
return true, ""
}
}
return false, fmt.Sprintf(
"Expected the following view lines:\n-----\n%s\n-----\nBut got:\n-----\n%s\n-----",
expectedContentFromMatchers(matchers),
strings.Join(lines, "\n"),
)
})
return self
}
func (self *ViewDriver) ContainsColoredText(fgColorStr string, text string) *ViewDriver {
self.t.assertWithRetries(func() (bool, string) {
view := self.getView()
@@ -0,0 +1,42 @@
package main_view
import (
"strings"
"github.com/jesseduffield/lazygit/pkg/config"
. "github.com/jesseduffield/lazygit/pkg/integration/components"
)
var longLine = "start " + strings.Repeat("word ", 40) + "end"
var WrapOnlyTheDiff = NewIntegrationTest(NewIntegrationTestArgs{
Description: "Turning wrapping off for diffs leaves everything else the main view shows wrapped",
ExtraCmdArgs: []string{},
Skip: false,
SetupConfig: func(cfg *config.AppConfig) {
cfg.GetUserConfig().Gui.WrapLinesInDiffView = false
},
SetupRepo: func(shell *Shell) {
shell.CreateFileAndAdd("file1", "one\n")
shell.Commit(longLine)
shell.UpdateFile("file1", "one\n"+longLine+"\n")
},
Run: func(t *TestDriver, keys config.KeybindingConfig) {
// The option is about diffs, so the added line runs off the edge of the pane in
// one piece.
t.Views().Files().
IsFocused().
Tap(func() {
t.Views().Main().ContainsViewLines(Contains("start").Contains("end"))
})
// A branch's commit log is no diff, and the option leaves it alone: the same
// text is laid out over as many lines as it takes.
t.Views().Branches().
Focus()
t.Views().Main().
ContainsViewLines(Contains("end").DoesNotContain("start"))
},
})
+1
View File
@@ -482,6 +482,7 @@ var tests = []*components.IntegrationTest{
main_view.StageUnderUnsupportedDiffRenderer,
main_view.StartPatchFromAnotherCommit,
main_view.UnstageDiffLines,
main_view.WrapOnlyTheDiff,
misc.ConfirmOnQuit,
misc.CopyConfirmationMessageToClipboard,
misc.CopyToClipboard,