mirror of
https://github.com/realAscot/helix.git
synced 2025-09-14 04:03:03 +02:00
Add rotate_selections_{first,last}
commands (#13615)
This commit is contained in:
parent
01341cbbf6
commit
637274c4d4
@ -303,3 +303,5 @@
|
|||||||
| `extend_to_word` | Extend to a two-character label | select: `` gw `` |
|
| `extend_to_word` | Extend to a two-character label | select: `` gw `` |
|
||||||
| `goto_next_tabstop` | Goto next snippet placeholder | |
|
| `goto_next_tabstop` | Goto next snippet placeholder | |
|
||||||
| `goto_prev_tabstop` | Goto next snippet placeholder | |
|
| `goto_prev_tabstop` | Goto next snippet placeholder | |
|
||||||
|
| `rotate_selections_first` | Make the first selection your primary one | |
|
||||||
|
| `rotate_selections_last` | Make the last selection your primary one | |
|
||||||
|
@ -601,6 +601,8 @@ impl MappableCommand {
|
|||||||
extend_to_word, "Extend to a two-character label",
|
extend_to_word, "Extend to a two-character label",
|
||||||
goto_next_tabstop, "Goto next snippet placeholder",
|
goto_next_tabstop, "Goto next snippet placeholder",
|
||||||
goto_prev_tabstop, "Goto next snippet placeholder",
|
goto_prev_tabstop, "Goto next snippet placeholder",
|
||||||
|
rotate_selections_first, "Make the first selection your primary one",
|
||||||
|
rotate_selections_last, "Make the last selection your primary one",
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -5292,6 +5294,21 @@ fn rotate_selections_backward(cx: &mut Context) {
|
|||||||
rotate_selections(cx, Direction::Backward)
|
rotate_selections(cx, Direction::Backward)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn rotate_selections_first(cx: &mut Context) {
|
||||||
|
let (view, doc) = current!(cx.editor);
|
||||||
|
let mut selection = doc.selection(view.id).clone();
|
||||||
|
selection.set_primary_index(0);
|
||||||
|
doc.set_selection(view.id, selection);
|
||||||
|
}
|
||||||
|
|
||||||
|
fn rotate_selections_last(cx: &mut Context) {
|
||||||
|
let (view, doc) = current!(cx.editor);
|
||||||
|
let mut selection = doc.selection(view.id).clone();
|
||||||
|
let len = selection.len();
|
||||||
|
selection.set_primary_index(len - 1);
|
||||||
|
doc.set_selection(view.id, selection);
|
||||||
|
}
|
||||||
|
|
||||||
enum ReorderStrategy {
|
enum ReorderStrategy {
|
||||||
RotateForward,
|
RotateForward,
|
||||||
RotateBackward,
|
RotateBackward,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user