mirror of
https://github.com/jesseduffield/lazygit.git
synced 2025-07-01 00:54:58 +02:00
Make SelectedLine/SelectedLineIdx work in staging/stagingSecondary views
While we try to keep the view's cursor position in sync with the context state's selectedLineIdx (at least when pressing up or down), there are enough situations where the two run out of sync; for example when initially opening the view, or after staging a hunk, or when scrolling the view using the wheel. While it would be possible to fix these situations to keep them always in sync, it doesn't seem worth it, because the view's cursor position isn't really used for anything else. So we rather special-case the SelectedLine/SelectedLineIdx functions of ViewDriver to query the context state's selectedLineIdx directly if it is a patch explorer context.
This commit is contained in:
@ -5,8 +5,6 @@ import (
|
||||
. "github.com/jesseduffield/lazygit/pkg/integration/components"
|
||||
)
|
||||
|
||||
// TODO: find out why we can't use .SelectedLine() on the staging/stagingSecondary views.
|
||||
|
||||
var Unstaged = NewIntegrationTest(NewIntegrationTestArgs{
|
||||
Description: "Staging a couple files, going in the unstaged files menu, staging a line and committing",
|
||||
ExtraCmdArgs: "",
|
||||
@ -30,11 +28,13 @@ var Unstaged = NewIntegrationTest(NewIntegrationTestArgs{
|
||||
IsFocused().
|
||||
Tap(func() {
|
||||
t.Views().StagingSecondary().Content(DoesNotContain("+myfile content"))
|
||||
t.Views().Staging().SelectedLine(Equals("+myfile content"))
|
||||
}).
|
||||
// stage the first line
|
||||
PressPrimaryAction().
|
||||
Tap(func() {
|
||||
t.Views().Staging().Content(DoesNotContain("+myfile content"))
|
||||
t.Views().Staging().Content(DoesNotContain("+myfile content")).
|
||||
SelectedLine(Equals("+with a second line"))
|
||||
t.Views().StagingSecondary().Content(Contains("+myfile content"))
|
||||
}).
|
||||
Press(keys.Files.CommitChanges)
|
||||
|
Reference in New Issue
Block a user