jesseduffield.lazygit/pkg/integration/tests/ui/drag_beyond_viewport.go
Stefan Haller a85d6e0349 Add a test for dragging a range selection past the bottom of a panel
This is the other place that manages its own scroll position: while a
drag extends the selection to a line below the viewport, the view stays
put, and the drag autoscroller scrolls it one line at a time for as long
as the pointer stays there. Making the scroll automatic would centre the
selection instead, i.e. jump the view rather than scroll it.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-14 08:04:13 +02:00

38 lines
1.1 KiB
Go

package ui
import (
"fmt"
"github.com/jesseduffield/lazygit/pkg/config"
. "github.com/jesseduffield/lazygit/pkg/integration/components"
)
var DragBeyondViewport = NewIntegrationTest(NewIntegrationTestArgs{
Description: "Dragging a range selection beyond the bottom of the panel doesn't scroll the view",
ExtraCmdArgs: []string{},
Skip: false,
Width: 120,
Height: 30,
SetupConfig: func(config *config.AppConfig) {},
SetupRepo: func(shell *Shell) {
shell.EmptyCommit("initial commit")
for i := range 20 {
shell.CreateFile(fmt.Sprintf("file%02d", i), "")
}
},
Run: func(t *TestDriver, keys config.KeybindingConfig) {
t.Views().Files().
Focus().
OriginY(0).
// The pointer ends up below the panel, so the range extends to a line
// that isn't visible. Scrolling there is the drag autoscroller's job,
// which scrolls line by line for as long as the pointer stays there;
// the drag itself must leave the scroll position alone.
ClickAndHold(1, 1).
MouseMove(1, 8).
MouseRelease().
SelectedLineIdx(8).
OriginY(0)
},
})