Set mode to none when calling SetSelectionRangeAndMode with empty non-sticky range

So far, the only situation where we called SetSelectionRangeAndMode was one
where the range could only get larger (in startInteractiveRebaseWithEdit, in
which case update-ref todos can be inserted by the rebase). However, in the last
commit we introduced a new call site where the range can get smaller, including
being reduced to a single item. Since this is indistinguishable from a single
selection, set the mode to none in this case; without this, hitting escape would
seemingly do nothing because it collapses the empty range selection.
This commit is contained in:
Stefan Haller 2024-03-16 17:09:58 +01:00
parent 0608fc6471
commit 5c56bc7015

View file

@ -65,7 +65,11 @@ func (self *ListCursor) SetSelection(value int) {
func (self *ListCursor) SetSelectionRangeAndMode(selectedIdx, rangeStartIdx int, mode RangeSelectMode) {
self.selectedIdx = self.clampValue(selectedIdx)
self.rangeStartIdx = self.clampValue(rangeStartIdx)
self.rangeSelectMode = mode
if mode == RangeSelectModeNonSticky && selectedIdx == rangeStartIdx {
self.rangeSelectMode = RangeSelectModeNone
} else {
self.rangeSelectMode = mode
}
}
// Returns the selectedIdx, the rangeStartIdx, and the mode of the current selection.