From a85d6e03499e650f5ef84c80062a76ce375076ca Mon Sep 17 00:00:00 2001 From: Stefan Haller Date: Sat, 8 Aug 2026 15:32:08 +0200 Subject: [PATCH] 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) --- pkg/integration/tests/test_list.go | 1 + .../tests/ui/drag_beyond_viewport.go | 37 +++++++++++++++++++ 2 files changed, 38 insertions(+) create mode 100644 pkg/integration/tests/ui/drag_beyond_viewport.go diff --git a/pkg/integration/tests/test_list.go b/pkg/integration/tests/test_list.go index c9f4f975d..ab7bf196c 100644 --- a/pkg/integration/tests/test_list.go +++ b/pkg/integration/tests/test_list.go @@ -500,6 +500,7 @@ var tests = []*components.IntegrationTest{ ui.BranchesNotFirstTab, ui.CommitsNotFirstTab, ui.DisableSwitchTabWithPanelJumpKeys, + ui.DragBeyondViewport, ui.EmptyMenu, ui.HideSidePanel, ui.KeybindingSuggestionsDontCrashOnDisabledBindings, diff --git a/pkg/integration/tests/ui/drag_beyond_viewport.go b/pkg/integration/tests/ui/drag_beyond_viewport.go new file mode 100644 index 000000000..f756a783c --- /dev/null +++ b/pkg/integration/tests/ui/drag_beyond_viewport.go @@ -0,0 +1,37 @@ +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) + }, +})