Skip to content

Commit 10dbdf7

Browse files
committed
feat: add goto_first_selection, goto_last_selection
1 parent 2bd7452 commit 10dbdf7

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed

book/src/generated/static-cmd.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -303,3 +303,5 @@
303303
| `extend_to_word` | Extend to a two-character label | select: `` gw `` |
304304
| `goto_next_tabstop` | Goto next snippet placeholder | |
305305
| `goto_prev_tabstop` | Goto next snippet placeholder | |
306+
| `goto_first_selection` | Make the first selection your primary one | |
307+
| `goto_last_selection` | Make the last selection your primary one | |

helix-term/src/commands.rs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -601,6 +601,8 @@ impl MappableCommand {
601601
extend_to_word, "Extend to a two-character label",
602602
goto_next_tabstop, "Goto next snippet placeholder",
603603
goto_prev_tabstop, "Goto next snippet placeholder",
604+
goto_first_selection, "Make the first selection your primary one",
605+
goto_last_selection, "Make the last selection your primary one",
604606
);
605607
}
606608

@@ -5290,6 +5292,21 @@ fn rotate_selections_backward(cx: &mut Context) {
52905292
rotate_selections(cx, Direction::Backward)
52915293
}
52925294

5295+
pub fn goto_first_selection(cx: &mut Context) {
5296+
let (view, doc) = current!(cx.editor);
5297+
let mut selection = doc.selection(view.id).clone();
5298+
selection.set_primary_index(0);
5299+
doc.set_selection(view.id, selection);
5300+
}
5301+
5302+
pub fn goto_last_selection(cx: &mut Context) {
5303+
let (view, doc) = current!(cx.editor);
5304+
let mut selection = doc.selection(view.id).clone();
5305+
let len = selection.len();
5306+
selection.set_primary_index(len - 1);
5307+
doc.set_selection(view.id, selection);
5308+
}
5309+
52935310
enum ReorderStrategy {
52945311
RotateForward,
52955312
RotateBackward,

0 commit comments

Comments
 (0)