Add tests for renders that don't show after scrolling far down a diff

If the main view is scrolled more than about 5000 lines down a diff and
another commit is selected, the main view keeps showing the previous
diff, as long as the new one is longer than 5000 lines as well.

Similarly, if the jump-to-file menu of the commits panel is used to go
to the last file of such a diff, the file's header ends up at the top
of the view with blank space below the end of the diff. This happens
even with gui.scrollPastBottom set to false.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
Stefan Haller
2026-10-13 16:18:52 +02:00
co-authored by Claude Opus 5.5
parent b741725a24
commit 29942337f5
3 changed files with 110 additions and 0 deletions
@@ -0,0 +1,53 @@
package main_view
import (
"fmt"
"strings"
"github.com/jesseduffield/lazygit/pkg/config"
. "github.com/jesseduffield/lazygit/pkg/integration/components"
)
var JumpToTheLastFileOfALongDiff = NewIntegrationTest(NewIntegrationTestArgs{
Description: "Jumping to the last file of a long diff from the commits panel doesn't scroll past the end of the diff",
ExtraCmdArgs: []string{},
Skip: false,
Width: 100,
Height: 20,
SetupConfig: func(config *config.AppConfig) {
config.GetUserConfig().Gui.ScrollPastBottom = false
},
SetupRepo: func(shell *Shell) {
// Longer than the 5000 lines that a render reads at most before it waits for
// the user to scroll further.
lines := make([]string, 6000)
for i := range lines {
lines[i] = fmt.Sprintf("line%04d", i+1)
}
shell.CreateFileAndAdd("long.txt", strings.Join(lines, "\n")+"\n")
shell.CreateFileAndAdd("short.txt", "one\n")
shell.Commit("first commit")
},
Run: func(t *TestDriver, keys config.KeybindingConfig) {
t.Views().Commits().
Focus().
SelectedLine(Contains("first commit")).
Press(keys.Universal.JumpToFile)
t.ExpectPopup().Menu().
Title(Equals("Jump to file in diff")).
Select(Equals("short.txt")).
Confirm()
t.Views().Commits().
IsFocused()
// The view shows the last screenful of the diff: the end of long.txt's diff,
// and all of short.txt's below it.
t.Views().Main().
/* EXPECTED:
TopVisibleLine(Equals("+line5994"))
ACTUAL: */
TopVisibleLine(Equals("diff --git a/short.txt b/short.txt"))
},
})
@@ -0,0 +1,55 @@
package main_view
import (
"fmt"
"strings"
"github.com/jesseduffield/lazygit/pkg/config"
. "github.com/jesseduffield/lazygit/pkg/integration/components"
)
var ShowAnotherLongDiffAfterScrollingFarDown = NewIntegrationTest(NewIntegrationTestArgs{
Description: "Selecting another commit shows its diff when the main view is scrolled far down a long diff",
ExtraCmdArgs: []string{},
Skip: false,
Width: 100,
Height: 20,
SetupConfig: func(config *config.AppConfig) {},
SetupRepo: func(shell *Shell) {
// Longer than the 5000 lines that a render reads at most before it waits for
// the user to scroll further.
lines := make([]string, 6000)
for i := range lines {
lines[i] = fmt.Sprintf("line%04d", i+1)
}
long := strings.Join(lines, "\n") + "\n"
shell.CreateFileAndAdd("first.txt", long)
shell.Commit("first commit")
shell.CreateFileAndAdd("second.txt", long)
shell.Commit("second commit")
},
Run: func(t *TestDriver, keys config.KeybindingConfig) {
t.Views().Commits().
Focus().
SelectedLine(Contains("second commit")).
Press(keys.Universal.FocusMainView)
t.Views().Main().
IsFocused().
Press(keys.Universal.GotoBottom).
SelectedLines(Contains("+line6000")).
Press(keys.Universal.Return)
t.Views().Commits().
IsFocused().
SelectNextItem().
SelectedLine(Contains("first commit"))
t.Views().Main().
/* EXPECTED:
Content(Contains("diff --git a/first.txt b/first.txt"))
ACTUAL: */
Content(Contains("diff --git a/second.txt b/second.txt"))
},
})
+2
View File
@@ -414,6 +414,7 @@ var tests = []*components.IntegrationTest{
main_view.JumpToAFileOfTheDiff,
main_view.JumpToAFileOnlyOverADiff,
main_view.JumpToAnotherFileScrollsToTheLeftEdge,
main_view.JumpToTheLastFileOfALongDiff,
main_view.KeepAWrappedLineCoveredAcrossARerender,
main_view.KeepAnEmptiedPaneEmpty,
main_view.KeepBothHalvesOfAChangeSelected,
@@ -493,6 +494,7 @@ var tests = []*components.IntegrationTest{
main_view.SelectionCommandTooltipsFollowTheDiff,
main_view.SelectionCommandsOnlyWhereTheyApply,
main_view.SelectionOverTheCustomPatch,
main_view.ShowAnotherLongDiffAfterScrollingFarDown,
main_view.ShowTheTabSwitchedToLast,
main_view.StageDeletedFile,
main_view.StageDiffLines,