feat(input): add Visual Line mode (V)#90
Open
roramirez wants to merge 1 commit into
Open
Conversation
`V` from Normal or Visual enters Visual LINE, where the selection always spans whole rows: `j`/`k` extend it line by line, `y` copies every selected line, `v` returns to characterwise, `Esc` exits. The status bar badge reads `V-LINE`. `InputMode::Visual` gains a `linewise` flag carried through every motion, scroll, and boundary-scroll reconstruction. Only two computations are linewise-aware: the renderer normalizes `selection_range` to full rows, and `do_visual_copy` passes column 0..cols-1 to `grid.selected_text` — whose `row_col_range` already yields vim's linewise yank semantics. `V` routes via a dedicated `Action::VisualLineAnchor` because `do_set_mode` discards keybinding-supplied fields on a Normal->Visual transition. Triple-click (`select_line_at`) now also enters Visual LINE, so a mouse-picked line can be extended with `j`/`k`.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds a vim-like linewise Visual mode.
V(from Normal or Visual) enters Visual LINE, where the selection always spans whole lines regardless of the cursor column:j/kextend it line by line,ycopies every selected line,vreturns to characterwise selection,Escexits. The status bar badge readsV-LINE.The mouse path is unified too: triple-click (
select_line_at) now leaves the user in Visual LINE, so a mouse-picked line can keep being extended withj/k. Its immediate copy yields identical text to before.Changes
InputMode::Visualgains alinewise: boolfield, carried unchanged through every reconstruction of the variant (motions, scroll, boundary scroll, swap anchor).Action::VisualLineAnchor+AppState::set_visual_line_anchor(), routed from bothdispatch_visual_actionanddispatch_action. A dedicated action is required becausedo_set_modediscards keybinding-supplied fields on a Normal→Visual transition, which would silently drop the flag."V"bound in both the Normal-mode handler andvisual_char_action;"v"now explicitly clearslinewise, making it the way back to charwise.selection_rangeinsrc/renderer/text.rsnormalizes to(0, start_row, cols-1, cur_row), so nothing downstream in the render pipeline changes.do_visual_copypassessc = 0, ec = cols-1;grid.selected_text's existingrow_col_rangealready makes interior rows full-width, giving exact vim linewise semantics (trailing-space trim,\njoin).grid.rsis untouched.mode_stylerendersV-LINEwhen linewise, reusing the sametheme.palette[5]color asVISUAL.select_line_atbuilds its mode withlinewise: true.CHANGELOG.md,README.md,doc/SPEC.md, and the Visual Mode section ofdoc/LLMs.md.How to test
cargo fmt --check cargo clippy --locked -- -D warnings cargo test1245 tests pass. New coverage:
src/input/keybindings_test.rs—VyieldsVisualLineAnchorfrom Normal and Visual; all motions (h/j/k/l/0/$/g/G, arrows, Home/End) preservelinewise;vreturns to charwise. Modifier combos per CLAUDE.md: Ctrl+V and Ctrl+Shift+V do not produceVisualLineAnchor, Shift+V in Insert does not, and Alt+V is asserted to fall through like every other Visual char key (pre-existing behavior for the whole Visual keymap, documented in the test).src/app_state_test.rs—VisualLineAnchoryieldsanchored: true, linewise: truefrom both Normal and Visual;VisualAnchorclears the flag; a multi-row linewiseCopyreturns full rows ("hello\nworld") rather than the column-clipped span; boundary scroll, viewport scroll, and swap-anchor all preservelinewise; andV+yover one row produces byte-identical text to the triple-click path.src/renderer/text_test.rs— a linewise selection highlights full rows without panicking;mode_stylereportsV-LINEwith the same color asVISUAL.Manually: run mmterm,
Ctrl+.twice into Visual, pressV, extend withj/k,yto copy, then paste to confirm whole lines. Triple-click a line and pressjto confirm it extends.Note:
cargo clippy --all-targetsreports pre-existing lints (useless_vec,dropping_copy_types) in test files untouched by this branch; the CLAUDE.md-mandatedcargo clippy --locked -- -D warningsis clean.