Add a test showing that commits search doesn't scroll to an off-screen match

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Stefan Haller
2026-11-07 20:14:38 +01:00
co-authored by Claude Opus 5.5
parent 84a7967e49
commit 74569cf535
2 changed files with 51 additions and 0 deletions
@@ -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)
},
})
+1
View File
@@ -176,6 +176,7 @@ var tests = []*components.IntegrationTest{
commit.Search,
commit.SearchKeepsTheCurrentMatchOnRefresh,
commit.SearchKeepsTheSecondMatchOnALineOnRefresh,
commit.SearchScrollsToAMatchOffTheEdge,
commit.SetAuthor,
commit.SetAuthorRange,
commit.StageRangeOfLines,