editor: Reverse range of pending selection if required (#38410)

cc https://github.com/zed-industries/zed/issues/38129

Release Notes:

- N/A *or* Added/Fixed/Improved ...
This commit is contained in:
Lukas Wirth
2025-09-18 10:58:10 +00:00
committed by GitHub
parent 59a609c9fc
commit b1aa2723e9
+17 -6
View File
@@ -469,13 +469,24 @@ impl<'a> MutableSelectionsCollection<'a> {
}
pub(crate) fn set_pending_anchor_range(&mut self, range: Range<Anchor>, mode: SelectMode) {
let buffer = self.buffer.read(self.cx).snapshot(self.cx);
self.collection.pending = Some(PendingSelection {
selection: Selection {
id: post_inc(&mut self.collection.next_selection_id),
start: range.start,
end: range.end,
reversed: false,
goal: SelectionGoal::None,
selection: {
let mut start = range.start;
let mut end = range.end;
let reversed = if start.cmp(&end, &buffer).is_gt() {
mem::swap(&mut start, &mut end);
true
} else {
false
};
Selection {
id: post_inc(&mut self.collection.next_selection_id),
start,
end,
reversed,
goal: SelectionGoal::None,
}
},
mode,
});