From 0b47b0013a089912973eb467fb9255ec5e5f30d9 Mon Sep 17 00:00:00 2001 From: Stefan Haller Date: Thu, 20 Aug 2026 21:34:03 +0200 Subject: [PATCH] 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) --- pkg/gui/main_panels.go | 4 ++ .../tests/main_view/wrap_only_the_diff.go | 42 +++++++++++++++++++ pkg/integration/tests/test_list.go | 1 + 3 files changed, 47 insertions(+) create mode 100644 pkg/integration/tests/main_view/wrap_only_the_diff.go diff --git a/pkg/gui/main_panels.go b/pkg/gui/main_panels.go index c5439c58c..dbad48cbb 100644 --- a/pkg/gui/main_panels.go +++ b/pkg/gui/main_panels.go @@ -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 { diff --git a/pkg/integration/tests/main_view/wrap_only_the_diff.go b/pkg/integration/tests/main_view/wrap_only_the_diff.go new file mode 100644 index 000000000..95294d0ce --- /dev/null +++ b/pkg/integration/tests/main_view/wrap_only_the_diff.go @@ -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")) + }, +}) diff --git a/pkg/integration/tests/test_list.go b/pkg/integration/tests/test_list.go index 567402ae6..997aa28db 100644 --- a/pkg/integration/tests/test_list.go +++ b/pkg/integration/tests/test_list.go @@ -485,6 +485,7 @@ var tests = []*components.IntegrationTest{ main_view.StageUnderUnsupportedDiffRenderer, main_view.StartPatchFromAnotherCommit, main_view.UnstageDiffLines, + main_view.WrapOnlyTheDiff, misc.ConfirmOnQuit, misc.CopyConfirmationMessageToClipboard, misc.CopyToClipboard,