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:
@@ -469,13 +469,24 @@ impl<'a> MutableSelectionsCollection<'a> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) fn set_pending_anchor_range(&mut self, range: Range<Anchor>, mode: SelectMode) {
|
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 {
|
self.collection.pending = Some(PendingSelection {
|
||||||
selection: Selection {
|
selection: {
|
||||||
id: post_inc(&mut self.collection.next_selection_id),
|
let mut start = range.start;
|
||||||
start: range.start,
|
let mut end = range.end;
|
||||||
end: range.end,
|
let reversed = if start.cmp(&end, &buffer).is_gt() {
|
||||||
reversed: false,
|
mem::swap(&mut start, &mut end);
|
||||||
goal: SelectionGoal::None,
|
true
|
||||||
|
} else {
|
||||||
|
false
|
||||||
|
};
|
||||||
|
Selection {
|
||||||
|
id: post_inc(&mut self.collection.next_selection_id),
|
||||||
|
start,
|
||||||
|
end,
|
||||||
|
reversed,
|
||||||
|
goal: SelectionGoal::None,
|
||||||
|
}
|
||||||
},
|
},
|
||||||
mode,
|
mode,
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user