Fix Vim Ngg ignoring the count (jump to line N like NG)#13133
Conversation
A count before gg was being dropped: 5gg jumped to the first line instead of line 5, even though 5G correctly jumps to line 5. The same applied to the operator-pending and visual variants (d5gg, v5gg). The gg arms in the normal, operator-pending, and visual handlers always emitted JumpToFirstLine and never read the pending count, while the matching G arms right next to them already branch on the count (get_action_count / get_operand_count) and emit JumpToLine. Make the three gg arms mirror their G siblings: with a count they emit JumpToLine(n); with no count they keep emitting JumpToFirstLine.
|
Every PR must be linked to a same-repo issue before Oz can review it. This PR is linked to #13132, but no linked issue is marked See the contribution guidelines for the full readiness model. Powered by Oz |
There was a problem hiding this comment.
Every PR must be linked to a same-repo issue before Oz can review it.
This PR is linked to #13132, but no linked issue is marked ready-to-implement yet. Only repository maintainers apply that label, so please wait for a maintainer to mark the issue. Once it is marked, push a new commit or comment /oz-review to re-trigger review.
See the contribution guidelines for the full readiness model.
Powered by Oz
|
/oz-reivew |
Description
In Vim mode, a count before
ggwas being dropped:5ggjumped to the first line instead of line 5, even though5Gcorrectly jumps to line 5. The same applied to the operator-pending and visual variants (d5gg,v5gg).The
ggarms in the normal, operator-pending, and visual handlers always emittedJumpToFirstLineand never read the pending count, while the matchingGarms right next to them already branch on the count (get_action_count()/get_operand_count()) and emitJumpToLine(n). This makes the threeggarms mirror theirGsiblings: with a count they emitJumpToLine(n), and with no count they keep emittingJumpToFirstLine.Linked Issue
Closes #13132
ready-to-specorready-to-implement.Testing
./script/runAdded
crates/vim/src/vim_tests.rs, which drives the state machine through key sequences and checks the event it emits:5gg/12gg→JumpToLine(n), and12ggproduces the same motion as12Gv5gg→JumpToLine(5)d3gg→ a delete operation with aJumpToLine(3)motiongg(no count) → stillJumpToFirstLineI confirmed these tests fail on
master(they emitJumpToFirstLinefor the counted cases) and pass with the fix.cargo test -p vim,cargo fmt -p vim, andcargo clippy -p vimare all clean.Agent Mode
CHANGELOG-BUG-FIX: Fixed a count before
ggbeing ignored in the Vim code editor —5ggnow jumps to line 5, matching5G.