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,