summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStefan Haller <stefan@haller-berlin.de>2024-03-16 17:09:58 +0100
committerStefan Haller <stefan@haller-berlin.de>2024-03-16 22:01:13 +0100
commit5c56bc7015ec635245d6270287508851276a040f (patch)
treec7157bc0767cea290069b2ef7ac4aceabf8b64d1
parent0608fc6471eacd2c4ffe33315972019839fc048b (diff)
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.
-rw-r--r--pkg/gui/context/traits/list_cursor.go6
1 files changed, 5 insertions, 1 deletions
diff --git a/pkg/gui/context/traits/list_cursor.go b/pkg/gui/context/traits/list_cursor.go
index 3b4ab1c3d..31f3de7a4 100644
--- a/pkg/gui/context/traits/list_cursor.go
+++ b/pkg/gui/context/traits/list_cursor.go
@@ -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.