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
|
@ -17,7 +17,7 @@
|
||||||
"alt-g alt-g": "go_to_line::Toggle", // goto-line
|
"alt-g alt-g": "go_to_line::Toggle", // goto-line
|
||||||
"ctrl-space": "editor::SetMark", // set-mark
|
"ctrl-space": "editor::SetMark", // set-mark
|
||||||
"ctrl-@": "editor::SetMark", // set-mark
|
"ctrl-@": "editor::SetMark", // set-mark
|
||||||
"ctrl-x ctrl-x": "editor::ExchangeMark", // exchange-point-and-mark
|
"ctrl-x ctrl-x": "editor::SwapSelectionEnds", // exchange-point-and-mark
|
||||||
"ctrl-f": "editor::MoveRight", // forward-char
|
"ctrl-f": "editor::MoveRight", // forward-char
|
||||||
"ctrl-b": "editor::MoveLeft", // backward-char
|
"ctrl-b": "editor::MoveLeft", // backward-char
|
||||||
"ctrl-n": "editor::MoveDown", // next-line
|
"ctrl-n": "editor::MoveDown", // next-line
|
||||||
|
|
|
@ -17,7 +17,7 @@
|
||||||
"alt-g alt-g": "go_to_line::Toggle", // goto-line
|
"alt-g alt-g": "go_to_line::Toggle", // goto-line
|
||||||
"ctrl-space": "editor::SetMark", // set-mark
|
"ctrl-space": "editor::SetMark", // set-mark
|
||||||
"ctrl-@": "editor::SetMark", // set-mark
|
"ctrl-@": "editor::SetMark", // set-mark
|
||||||
"ctrl-x ctrl-x": "editor::ExchangeMark", // exchange-point-and-mark
|
"ctrl-x ctrl-x": "editor::SwapSelectionEnds", // exchange-point-and-mark
|
||||||
"ctrl-f": "editor::MoveRight", // forward-char
|
"ctrl-f": "editor::MoveRight", // forward-char
|
||||||
"ctrl-b": "editor::MoveLeft", // backward-char
|
"ctrl-b": "editor::MoveLeft", // backward-char
|
||||||
"ctrl-n": "editor::MoveDown", // next-line
|
"ctrl-n": "editor::MoveDown", // next-line
|
||||||
|
|
|
@ -377,7 +377,7 @@ gpui::actions!(
|
||||||
ToggleInlayHints,
|
ToggleInlayHints,
|
||||||
ToggleInlineCompletions,
|
ToggleInlineCompletions,
|
||||||
ToggleLineNumbers,
|
ToggleLineNumbers,
|
||||||
ExchangeMark,
|
SwapSelectionEnds,
|
||||||
SetMark,
|
SetMark,
|
||||||
ToggleRelativeLineNumbers,
|
ToggleRelativeLineNumbers,
|
||||||
ToggleSelectionMenu,
|
ToggleSelectionMenu,
|
||||||
|
|
|
@ -10633,17 +10633,18 @@ impl Editor {
|
||||||
cx.notify();
|
cx.notify();
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn exchange_mark(&mut self, _: &actions::ExchangeMark, cx: &mut ViewContext<Self>) {
|
pub fn swap_selection_ends(
|
||||||
if self.selection_mark_mode {
|
&mut self,
|
||||||
self.change_selections(None, cx, |s| {
|
_: &actions::SwapSelectionEnds,
|
||||||
s.move_with(|_, sel| {
|
cx: &mut ViewContext<Self>,
|
||||||
if sel.start != sel.end {
|
) {
|
||||||
sel.reversed = !sel.reversed
|
self.change_selections(None, cx, |s| {
|
||||||
}
|
s.move_with(|_, sel| {
|
||||||
});
|
if sel.start != sel.end {
|
||||||
})
|
sel.reversed = !sel.reversed
|
||||||
}
|
}
|
||||||
self.selection_mark_mode = true;
|
});
|
||||||
|
});
|
||||||
cx.notify();
|
cx.notify();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -357,7 +357,7 @@ impl EditorElement {
|
||||||
register_action(view, cx, Editor::unfold_at);
|
register_action(view, cx, Editor::unfold_at);
|
||||||
register_action(view, cx, Editor::fold_selected_ranges);
|
register_action(view, cx, Editor::fold_selected_ranges);
|
||||||
register_action(view, cx, Editor::set_mark);
|
register_action(view, cx, Editor::set_mark);
|
||||||
register_action(view, cx, Editor::exchange_mark);
|
register_action(view, cx, Editor::swap_selection_ends);
|
||||||
register_action(view, cx, Editor::show_completions);
|
register_action(view, cx, Editor::show_completions);
|
||||||
register_action(view, cx, Editor::toggle_code_actions);
|
register_action(view, cx, Editor::toggle_code_actions);
|
||||||
register_action(view, cx, Editor::open_excerpts);
|
register_action(view, cx, Editor::open_excerpts);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue