Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix non-sticky range select after clicking in staging view #3998

Merged
merged 3 commits into from
Oct 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions pkg/gui/gui_driver.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,11 @@ func (self *GuiDriver) Click(x, y int) {
0,
)
self.waitTillIdle()
self.gui.g.ReplayedEvents.MouseEvents <- gocui.NewTcellMouseEventWrapper(
tcell.NewEventMouse(x, y, tcell.ButtonNone, 0),
0,
)
self.waitTillIdle()
}

// wait until lazygit is idle (i.e. all processing is done) before continuing
Expand Down
2 changes: 1 addition & 1 deletion pkg/gui/patch_exploring/state.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ func (s *State) ToggleStickySelectRange() {
}

func (s *State) ToggleSelectRange(sticky bool) {
if s.selectMode == RANGE {
if s.SelectingRange() {
s.selectMode = LINE
} else {
s.selectMode = RANGE
Expand Down
18 changes: 15 additions & 3 deletions pkg/integration/tests/ui/range_select.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ var RangeSelect = NewIntegrationTest(NewIntegrationTestArgs{
shell.CreateFile("file1", fileContent)
},
Run: func(t *TestDriver, keys config.KeybindingConfig) {
assertRangeSelectBehaviour := func(v *ViewDriver) {
assertRangeSelectBehaviour := func(v *ViewDriver, otherView *ViewDriver, lineIdxOfFirstItem int) {
v.
SelectedLines(
Contains("line 1"),
Expand Down Expand Up @@ -152,9 +152,21 @@ var RangeSelect = NewIntegrationTest(NewIntegrationTestArgs{
SelectedLines(
Contains("line 10"),
)

// Click in view, press shift+arrow -> nonsticky range
otherView.Focus()
v.Click(1, lineIdxOfFirstItem).
SelectedLines(
Contains("line 1"),
).
Press(keys.Universal.RangeSelectDown).
SelectedLines(
Contains("line 1"),
Contains("line 2"),
)
}

assertRangeSelectBehaviour(t.Views().Commits().Focus())
assertRangeSelectBehaviour(t.Views().Commits().Focus(), t.Views().Branches(), 0)

t.Views().Files().
Focus().
Expand All @@ -163,6 +175,6 @@ var RangeSelect = NewIntegrationTest(NewIntegrationTestArgs{
).
PressEnter()

assertRangeSelectBehaviour(t.Views().Staging().IsFocused())
assertRangeSelectBehaviour(t.Views().Staging().IsFocused(), t.Views().Files(), 6)
},
})
Loading