diff --git a/pkg/gui/controllers/patch_explorer_controller.go b/pkg/gui/controllers/patch_explorer_controller.go index caac1f51cc2..957705bd1ea 100644 --- a/pkg/gui/controllers/patch_explorer_controller.go +++ b/pkg/gui/controllers/patch_explorer_controller.go @@ -274,7 +274,7 @@ func (self *PatchExplorerController) HandleMouseDown() error { } func (self *PatchExplorerController) HandleMouseDrag() error { - self.context.GetState().SelectLine(self.context.GetViewTrait().SelectedLineIdx()) + self.context.GetState().DragSelectLine(self.context.GetViewTrait().SelectedLineIdx()) return nil } diff --git a/pkg/gui/patch_exploring/state.go b/pkg/gui/patch_exploring/state.go index ccd30d03fcc..730deb0c1fd 100644 --- a/pkg/gui/patch_exploring/state.go +++ b/pkg/gui/patch_exploring/state.go @@ -49,12 +49,10 @@ func NewState(diff string, selectedLineIdx int, oldState *State, log *logrus.Ent } selectMode := LINE - rangeIsSticky := false // if we have clicked from the outside to focus the main view we'll pass in a non-negative line index so that we can instantly select that line if selectedLineIdx >= 0 { selectMode = RANGE rangeStartLineIdx = selectedLineIdx - rangeIsSticky = true } else if oldState != nil { // if we previously had a selectMode of RANGE, we want that to now be line again if oldState.selectMode == HUNK { @@ -70,7 +68,7 @@ func NewState(diff string, selectedLineIdx int, oldState *State, log *logrus.Ent selectedLineIdx: selectedLineIdx, selectMode: selectMode, rangeStartLineIdx: rangeStartLineIdx, - rangeIsSticky: rangeIsSticky, + rangeIsSticky: false, diff: diff, } } @@ -150,7 +148,12 @@ func (s *State) SelectNewLineForRange(newSelectedLineIdx int) { s.rangeStartLineIdx = newSelectedLineIdx s.selectMode = RANGE - s.rangeIsSticky = true + + s.selectLineWithoutRangeCheck(newSelectedLineIdx) +} + +func (s *State) DragSelectLine(newSelectedLineIdx int) { + s.selectMode = RANGE s.selectLineWithoutRangeCheck(newSelectedLineIdx) }