Add support for editor::SwapSelectionEnds
everywhere (emacs exchange-point-and-mark) (#23428)
Add `editor:: SwapSelectionEnds ` action which swaps the cursor location from the beginning/end of a given selection. Renamed from `editor::ExchangeMark` to `editor::SwapSelectionEnds`. Unbound by default, bound to `ctrl-x ctrl-x` in Emacs keymap.
This commit is contained in:
parent
31909bf334
commit
3d47f32f0c
5 changed files with 16 additions and 15 deletions
|
@ -10633,17 +10633,18 @@ impl Editor {
|
|||
cx.notify();
|
||||
}
|
||||
|
||||
pub fn exchange_mark(&mut self, _: &actions::ExchangeMark, cx: &mut ViewContext<Self>) {
|
||||
if self.selection_mark_mode {
|
||||
self.change_selections(None, cx, |s| {
|
||||
s.move_with(|_, sel| {
|
||||
if sel.start != sel.end {
|
||||
sel.reversed = !sel.reversed
|
||||
}
|
||||
});
|
||||
})
|
||||
}
|
||||
self.selection_mark_mode = true;
|
||||
pub fn swap_selection_ends(
|
||||
&mut self,
|
||||
_: &actions::SwapSelectionEnds,
|
||||
cx: &mut ViewContext<Self>,
|
||||
) {
|
||||
self.change_selections(None, cx, |s| {
|
||||
s.move_with(|_, sel| {
|
||||
if sel.start != sel.end {
|
||||
sel.reversed = !sel.reversed
|
||||
}
|
||||
});
|
||||
});
|
||||
cx.notify();
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue