Skip to content

Commit

Permalink
Fix pressing shift-down after clicking in diff view
Browse files Browse the repository at this point in the history
When clicking in a single-file diff view to enter staging (or custom patch
editing, when coming from the commit files panel), and then pressing shift-down
or shift-up to select a range, it would move the selected line rather than
creating a range. Only on the next press would it start to select a range from
there.

This is very similar to the fix we made for pressing escape in 0e4d266.
  • Loading branch information
stefanhaller committed Oct 18, 2024
1 parent 7655f68 commit a58770e
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 11 deletions.
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
12 changes: 2 additions & 10 deletions pkg/integration/tests/ui/range_select.go
Original file line number Diff line number Diff line change
Expand Up @@ -159,19 +159,11 @@ var RangeSelect = NewIntegrationTest(NewIntegrationTestArgs{
SelectedLines(
Contains("line 1"),
).
Press(keys.Universal.RangeSelectDown)
if lineIdxOfFirstItem == 6 {
v.SelectedLines(
// bug: it moved to line 2 instead of selecting both line 1 and line 2
Contains("line 2"),
)
} else {
// works correctly in list views though
v.SelectedLines(
Press(keys.Universal.RangeSelectDown).
SelectedLines(
Contains("line 1"),
Contains("line 2"),
)
}
}

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

0 comments on commit a58770e

Please sign in to comment.