Skip to content

feat(editor): restore and indent visual selections - #205

Merged
fcoury merged 2 commits into
mainfrom
feat/visual-selection-commands
Aug 14, 2026
Merged

fcoury merged 2 commits into
mainfrom
feat/visual-selection-commands

Conversation

@fcoury

@fcoury fcoury commented Aug 14, 2026 •

Copy link
Copy Markdown
Contributor

Why

Red tracked the < and > marks for the most recent Visual selection, but it did not retain the selection shape or expose Vim's gv command. Visual selections also could not be shifted with > or <, leaving two common Vim editing workflows incomplete.

Closes #198.
Closes #199.

What Changed

  • Retain buffer-local Visual mode and direction alongside edit-aware selection marks, including across session recovery.
  • Map gv in Normal and Visual modes to restore or exchange the previous character-, line-, or blockwise area.
  • Add counted Visual indentation and unindentation across every covered line as one undoable transaction, while leaving empty lines unchanged and clamping left shifts at column zero.
  • Document the supported behavior and add configuration, session-recovery, and editing coverage.

How to Test

  1. Open a buffer, make characterwise, linewise, and blockwise Visual selections, press Escape, and then press gv.
    • Expected: Red restores the same area, Visual mode, and selection direction.
  2. While already in Visual mode, select a different area and press gv twice.
    • Expected: the current and previous areas exchange each time.
  3. Select multiple lines with V, press 2>, and then press u followed by gv.
    • Expected: each non-empty selected line shifts right by two shiftwidth units in one undo step, undo restores all lines together, and gv reselects the range.
  4. Select lines with different indentation depths, including one indented by less than two shiftwidth units, and press 2<.
    • Expected: each selected line shifts left by up to two shiftwidth units in one undo step, and shallower lines stop at column zero.
  5. Recover a session after recording a linewise or blockwise selection, then press gv.
    • Expected: Red restores the recovered selection shape and bounds.

Targeted automated coverage is included in tests/editing.rs and src/config.rs. cargo test --all-features and cargo clippy --all-targets --all-features -- -D warnings pass.

@fcoury
fcoury merged commit aed51c3 into main Aug 14, 2026
18 checks passed
@fcoury
fcoury deleted the feat/visual-selection-commands branch August 14, 2026 22:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Implement > to indent selection Implement gv to restore last selection

1 participant