Skip to content
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
2 changes: 0 additions & 2 deletions pkg/gui/controllers/patch_explorer_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -244,14 +244,12 @@ func (self *PatchExplorerController) HandleScrollRight() error {
}

func (self *PatchExplorerController) HandlePrevPage() error {
self.context.GetState().SetLineSelectMode()
self.context.GetState().AdjustSelectedLineIdx(-self.context.GetViewTrait().PageDelta())

return nil
}

func (self *PatchExplorerController) HandleNextPage() error {
self.context.GetState().SetLineSelectMode()
self.context.GetState().AdjustSelectedLineIdx(self.context.GetViewTrait().PageDelta())

return nil
Expand Down
11 changes: 9 additions & 2 deletions pkg/gui/patch_exploring/state.go
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,12 @@ func (s *State) SetLineSelectMode() {
s.selectMode = LINE
}

func (s *State) DismissHunkSelectMode() {
if s.SelectingHunk() {
s.selectMode = LINE
}
}

// For when you move the cursor without holding shift (meaning if we're in
// a non-sticky range select, we'll cancel it)
func (s *State) SelectLine(newSelectedLineIdx int) {
Expand Down Expand Up @@ -239,6 +245,7 @@ func (s *State) CurrentLineNumber() int {
}

func (s *State) AdjustSelectedLineIdx(change int) {
s.DismissHunkSelectMode()
s.SelectLine(s.selectedLineIdx + change)
}

Expand All @@ -255,12 +262,12 @@ func (s *State) PlainRenderSelected() string {
}

func (s *State) SelectBottom() {
s.SetLineSelectMode()
s.DismissHunkSelectMode()
s.SelectLine(s.patch.LineCount() - 1)
}

func (s *State) SelectTop() {
s.SetLineSelectMode()
s.DismissHunkSelectMode()
s.SelectLine(0)
}

Expand Down
10 changes: 5 additions & 5 deletions pkg/integration/tests/ui/range_select.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import (
// (sticky range, press 'v') -> no range
// (sticky range, press 'escape') -> no range
// (sticky range, press arrow) -> sticky range
// (sticky range, press `<`/`>` or `,`/`.`) -> sticky range
// (sticky range, press shift+arrow) -> nonsticky range
// (nonsticky range, press 'v') -> no range
// (nonsticky range, press 'escape') -> no range
Expand Down Expand Up @@ -138,19 +139,18 @@ var RangeSelect = NewIntegrationTest(NewIntegrationTestArgs{
SelectedLines(
Contains("line 8"),
).
// (sticky range, press '>') -> sticky range
Press(keys.Universal.ToggleRangeSelect).
SelectedLines(
Contains("line 8"),
).
SelectNextItem().
Press(keys.Universal.GotoBottom).
SelectedLines(
Contains("line 8"),
Contains("line 9"),
Contains("line 10"),
).
// (sticky range, press 'escape') -> no range
PressEscape().
SelectedLines(
Contains("line 9"),
Contains("line 10"),
)
}

Expand Down