diff --git a/pkg/integration/tests/commit/search_scrolls_to_a_match_off_the_edge.go b/pkg/integration/tests/commit/search_scrolls_to_a_match_off_the_edge.go new file mode 100644 index 000000000..1b27773e9 --- /dev/null +++ b/pkg/integration/tests/commit/search_scrolls_to_a_match_off_the_edge.go @@ -0,0 +1,50 @@ +package commit + +import ( + "fmt" + "strings" + + "github.com/jesseduffield/lazygit/pkg/config" + . "github.com/jesseduffield/lazygit/pkg/integration/components" +) + +var SearchScrollsToAMatchOffTheEdge = NewIntegrationTest(NewIntegrationTestArgs{ + Description: "Searching the commits panel scrolls it sideways to show a match past its right edge, also in a commit that was below the visible area", + ExtraCmdArgs: []string{}, + Skip: false, + Width: 120, + Height: 30, + SetupConfig: func(config *config.AppConfig) {}, + SetupRepo: func(shell *Shell) { + shell.NewBranch("branch") + for i := 1; i <= 30; i++ { + message := fmt.Sprintf("commit %02d", i) + switch i { + case 29: + message += " " + strings.Repeat("word ", 20) + "needle" + case 3: + message += " " + strings.Repeat("word ", 40) + "needle" + } + shell.EmptyCommit(message) + } + }, + Run: func(t *TestDriver, keys config.KeybindingConfig) { + t.Views().Commits(). + Focus(). + FilterOrSearch("needle"). + SelectedLines( + Contains("commit 29"), + ). + OriginX(112). + // Commit 03 is below the visible area, and its match is 100 columns + // further right than the one in commit 29. + Press(keys.Universal.NextMatch). + SelectedLines( + Contains("commit 03"), + ). + /* EXPECTED: + OriginX(212) + ACTUAL: */ + OriginX(112) + }, +}) diff --git a/pkg/integration/tests/test_list.go b/pkg/integration/tests/test_list.go index 6f08a6863..8402b1532 100644 --- a/pkg/integration/tests/test_list.go +++ b/pkg/integration/tests/test_list.go @@ -176,6 +176,7 @@ var tests = []*components.IntegrationTest{ commit.Search, commit.SearchKeepsTheCurrentMatchOnRefresh, commit.SearchKeepsTheSecondMatchOnALineOnRefresh, + commit.SearchScrollsToAMatchOffTheEdge, commit.SetAuthor, commit.SetAuthorRange, commit.StageRangeOfLines,