Skip to content

feat: add multi line navigation actions#96

Open
viastolfi wants to merge 1 commit into
webstonehq:mainfrom
viastolfi:feat/line_number_navigation
Open

feat: add multi line navigation actions#96
viastolfi wants to merge 1 commit into
webstonehq:mainfrom
viastolfi:feat/line_number_navigation

Conversation

@viastolfi

Copy link
Copy Markdown

Closes #78.

Adds a numeric count prefix to normal-mode cursor motions, vim-style: 5j moves the cursor down 5 rows, 12G jumps to row 12, 5gg does the same from the top. Previously every motion only moved one row at a time, with no way to jump further without repeating a key or reaching for the mouse/search.

Changes

  • New Count state machine (src/app/count.rs), modeled directly on the existing Chord: digits accumulate via push_digit and expire after the same LEADER_WINDOW idle timeout, so a stale prefix never leaks into an unrelated later keypress. Capped at 8 digits to stay well clear of u32 overflow.
  • Digit keys (0-9) are intercepted in resolve_normal_key before the action match, so they never collide with existing single-key bindings.
  • CursorDown/CursorUp treat the pending count as a repeat count; CursorTop/CursorBottom (gg/G) treat it as an absolute target line, clamped to the visible list bounds (no out-of-bounds cursor, no panic on an empty list).
  • Status bar shows a " 12…" indicator while a count is pending, mirroring the existing chord indicator (" g…"); count is shown first since it's typed first (e.g. 5gg).
  • Unit tests for Count covering accumulation, the 8-digit cap, and window expiry, following the same style as chord.rs's test suite.

Test plan

  • cargo fmt --check
  • cargo clippy --all-targets
  • cargo test

All pass.

Notes

  • HalfPageDown/HalfPageUp (Ctrl-d/Ctrl-u) intentionally don't consume a count yet — happy to wire that up too if useful, kept this PR scoped to the motions named in [feature request] Navigate by line number #78.
  • No visible cap-reached feedback (typing a 9th digit is silently ignored); didn't feel worth a UI change for an edge case, but open to adding one.

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.

[feature request] Navigate by line number

1 participant