@@ -406,6 +406,7 @@ impl MappableCommand {
406406 rotate_selections_backward, "Rotate selections backward",
407407 rotate_selection_contents_forward, "Rotate selection contents forward",
408408 rotate_selection_contents_backward, "Rotate selections contents backward",
409+ reverse_selection_contents, "Reverse selections contents",
409410 expand_selection, "Expand selection to parent syntax node",
410411 shrink_selection, "Shrink selection to previously expanded syntax node",
411412 select_next_sibling, "Select next sibling in syntax tree",
@@ -4482,7 +4483,13 @@ fn rotate_selections_backward(cx: &mut Context) {
44824483 rotate_selections(cx, Direction::Backward)
44834484}
44844485
4485−fn rotate_selection_contents(cx: &mut Context, direction: Direction) {
4486+enum ReorderStrategy {
4487+ RotateForward,
4488+ RotateBackward,
4489+ Reverse,
4490+}
4491+
4492+fn reorder_selection_contents(cx: &mut Context, strategy: ReorderStrategy) {
44864493 let count = cx.count;
44874494 let (view, doc) = current!(cx.editor);
44884495 let text = doc.text().slice(..);
@@ -4500,9 +4507,10 @@ fn rotate_selection_contents(cx: &mut Context, direction: Direction) {
45004507
45014508 for chunk in fragments.chunks_mut(group) {
45024509 // TODO: also modify main index
4503− match direction {
4504− Direction::Forward => chunk.rotate_right(1),
4505− Direction::Backward => chunk.rotate_left(1),
4510+ match strategy {
4511+ ReorderStrategy::RotateForward => chunk.rotate_right(1),
4512+ ReorderStrategy::RotateBackward => chunk.rotate_left(1),
4513+ ReorderStrategy::Reverse => chunk.reverse(),
45064514 };
45074515 }
45084516
@@ -4519,10 +4527,13 @@ fn rotate_selection_contents(cx: &mut Context, direction: Direction) {
45194527}
45204528
45214529fn rotate_selection_contents_forward(cx: &mut Context) {
4522− rotate_selection_contents(cx, Direction::Forward)
4530+ reorder_selection_contents(cx, ReorderStrategy::RotateForward)
45234531}
45244532fn rotate_selection_contents_backward(cx: &mut Context) {
4525− rotate_selection_contents(cx, Direction::Backward)
4533+ reorder_selection_contents(cx, ReorderStrategy::RotateBackward)
4534+}
4535+fn reverse_selection_contents(cx: &mut Context) {
4536+ reorder_selection_contents(cx, ReorderStrategy::Reverse)
45264537}
45274538
45284539// tree sitter node selection