fix(vim): respect count before gg (e.g. 5gg jumps to line 5)#13167
fix(vim): respect count before gg (e.g. 5gg jumps to line 5)#13167Jason-Shen2 wants to merge 2 commits into
Conversation
In Vim, Ngg is equivalent to NG — both jump to line N. Previously, the gg motion always jumped to line 1 regardless of any preceding count, so 5gg, d5gg, and v5gg all behaved as if no count was given. This change checks for a pending count before falling back to JumpToFirstLine, matching the existing handling for G. It applies to normal mode, operator-pending mode (d5gg, y5gg), and visual mode (v5gg, V5gg). Fixes warpdotdev#13132
|
Thank you for your pull request and welcome to our community. We could not parse the GitHub identity of the following contributors: zhenxing.shen.
|
|
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
|
@Jason-Shen2 Please be sure to sign the CLA here as that is a legal requirement to accept your code After that you can run "/oz-review" and when the bot review passes, I'll take a look |
|
Thank you for your pull request and welcome to our community. We require contributors to sign our Contributor License Agreement, and we don't seem to have the users @Jason-Shen2 on file. In order for us to review and merge your code, each contributor must visit https://cla.warp.dev to read and agree to our CLA. Once you have done so, please comment |
|
@cla-bot check |
|
The cla-bot has been summoned, and re-checked this pull request! |
|
@cla-bot check |
|
The cla-bot has been summoned, and re-checked this pull request! |
Summary
Fixes #13132
In Vim,
Nggis equivalent toNG— both jump to line N. Previously, theggmotion always jumped to line 1 regardless of any preceding count, so:5ggjumped to line 1 instead of line 5d5ggdeleted up to line 1 instead of line 5v5ggselected up to line 1 instead of line 5Root Cause
In
crates/vim/src/vim.rs, theggkey mapping (second 'g' after a pending G prefix) unconditionally returnedVimMotion::JumpToFirstLinewithout checking for a pending count, unlikeGwhich correctly usesget_action_count()/get_operand_count()to decide betweenJumpToLine(n)andJumpToLastLine.Fix
Added a count check before falling back to
JumpToFirstLine, matching the existing pattern used forG. The fix applies to all three modes whereggcan appear:handle_normal_pending_action): usesget_action_count()handle_normal_pending_operand): usesget_operand_count()(fixesd5gg,y5gg, etc.)handle_visual_pending_action): usesget_action_count()(fixesv5gg,V5gg)A bare
ggwith no count still jumps to the first line as expected.