From 29942337f55dd1b0683a981bd572b308823c76b9 Mon Sep 17 00:00:00 2001 From: Stefan Haller Date: Tue, 13 Oct 2026 16:18:52 +0200 Subject: [PATCH] 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) --- .../jump_to_the_last_file_of_a_long_diff.go | 53 ++++++++++++++++++ ...ther_long_diff_after_scrolling_far_down.go | 55 +++++++++++++++++++ pkg/integration/tests/test_list.go | 2 + 3 files changed, 110 insertions(+) create mode 100644 pkg/integration/tests/main_view/jump_to_the_last_file_of_a_long_diff.go create mode 100644 pkg/integration/tests/main_view/show_another_long_diff_after_scrolling_far_down.go diff --git a/pkg/integration/tests/main_view/jump_to_the_last_file_of_a_long_diff.go b/pkg/integration/tests/main_view/jump_to_the_last_file_of_a_long_diff.go new file mode 100644 index 000000000..fad3a21db --- /dev/null +++ b/pkg/integration/tests/main_view/jump_to_the_last_file_of_a_long_diff.go @@ -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")) + }, +}) diff --git a/pkg/integration/tests/main_view/show_another_long_diff_after_scrolling_far_down.go b/pkg/integration/tests/main_view/show_another_long_diff_after_scrolling_far_down.go new file mode 100644 index 000000000..094cb99ba --- /dev/null +++ b/pkg/integration/tests/main_view/show_another_long_diff_after_scrolling_far_down.go @@ -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")) + }, +}) diff --git a/pkg/integration/tests/test_list.go b/pkg/integration/tests/test_list.go index aea6c4f13..76b8b3357 100644 --- a/pkg/integration/tests/test_list.go +++ b/pkg/integration/tests/test_list.go @@ -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,