@@ -275,6 +275,8 @@ impl Command {
275 completion, "Invoke completion popup",
275 completion, "Invoke completion popup",
276 hover, "Show docs for item under cursor",
276 hover, "Show docs for item under cursor",
277 toggle_comments, "Comment/uncomment selections",
277 toggle_comments, "Comment/uncomment selections",
278+ rotate_selections_forward, "Rotate selections forward",
279+ rotate_selections_backward, "Rotate selections backward",
278 expand_selection, "Expand selection to parent syntax node",
280 expand_selection, "Expand selection to parent syntax node",
279 jump_forward, "Jump forward on jumplist",
281 jump_forward, "Jump forward on jumplist",
280 jump_backward, "Jump backward on jumplist",
282 jump_backward, "Jump backward on jumplist",
@@ -3747,6 +3749,25 @@ fn toggle_comments(cx: &mut Context) {
3747 doc.append_changes_to_history(view.id);
3749 doc.append_changes_to_history(view.id);
3752+fn rotate_selections(cx: &mut Context, direction: Direction) {
3753+ let count = cx.count();
3754+ let (view, doc) = current!(cx.editor);
3755+ let mut selection = doc.selection(view.id).clone();
3756+ let index = selection.primary_index();
3757+ let len = selection.len();
3758+ selection.set_primary_index(match direction {
3759+ Direction::Forward => (index + count) % len,
3760+ Direction::Backward => (index + (len.saturating_sub(count) % len)) % len,
3762+ doc.set_selection(view.id, selection);
3764+fn rotate_selections_forward(cx: &mut Context) {
3765+ rotate_selections(cx, Direction::Forward)
3767+fn rotate_selections_backward(cx: &mut Context) {
3768+ rotate_selections(cx, Direction::Backward)
3750// tree sitter node selection
3771// tree sitter node selection
3752fn expand_selection(cx: &mut Context) {
3773fn expand_selection(cx: &mut Context) {