Skip to content

Commit 7655f68

Browse files
committed
Add test demonstrating a bug with clicking in the staging view
When clicking in the main view to enter staging, and then pressing shift-down to select a range, it moves the selection rather than selecting a two-line range. We'll fix this in the next commit.
1 parent 286e5f4 commit 7655f68

File tree

1 file changed

+23
-3
lines changed

1 file changed

+23
-3
lines changed

pkg/integration/tests/ui/range_select.go

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ var RangeSelect = NewIntegrationTest(NewIntegrationTestArgs{
5050
shell.CreateFile("file1", fileContent)
5151
},
5252
Run: func(t *TestDriver, keys config.KeybindingConfig) {
53-
assertRangeSelectBehaviour := func(v *ViewDriver) {
53+
assertRangeSelectBehaviour := func(v *ViewDriver, otherView *ViewDriver, lineIdxOfFirstItem int) {
5454
v.
5555
SelectedLines(
5656
Contains("line 1"),
@@ -152,9 +152,29 @@ var RangeSelect = NewIntegrationTest(NewIntegrationTestArgs{
152152
SelectedLines(
153153
Contains("line 10"),
154154
)
155+
156+
// Click in view, press shift+arrow -> nonsticky range
157+
otherView.Focus()
158+
v.Click(1, lineIdxOfFirstItem).
159+
SelectedLines(
160+
Contains("line 1"),
161+
).
162+
Press(keys.Universal.RangeSelectDown)
163+
if lineIdxOfFirstItem == 6 {
164+
v.SelectedLines(
165+
// bug: it moved to line 2 instead of selecting both line 1 and line 2
166+
Contains("line 2"),
167+
)
168+
} else {
169+
// works correctly in list views though
170+
v.SelectedLines(
171+
Contains("line 1"),
172+
Contains("line 2"),
173+
)
174+
}
155175
}
156176

157-
assertRangeSelectBehaviour(t.Views().Commits().Focus())
177+
assertRangeSelectBehaviour(t.Views().Commits().Focus(), t.Views().Branches(), 0)
158178

159179
t.Views().Files().
160180
Focus().
@@ -163,6 +183,6 @@ var RangeSelect = NewIntegrationTest(NewIntegrationTestArgs{
163183
).
164184
PressEnter()
165185

166-
assertRangeSelectBehaviour(t.Views().Staging().IsFocused())
186+
assertRangeSelectBehaviour(t.Views().Staging().IsFocused(), t.Views().Files(), 6)
167187
},
168188
})

0 commit comments

Comments
 (0)