Repository navigation
mac: vim gj/gk (and g0/g^/g$) move by visual rows, not logical lines - #238
Merged
Merged
Conversation
Line wrapping defaults on, so a wrapped paragraph is one logical line spread over many screen rows. `j` moves a *line*, which means it leaps over the whole paragraph — the caret vanishes from where the user was looking. Vim's answer is `gj`/`gk`, and they were missing. `Motion` gains `visualDown`/`visualUp` and `rowStart`/`rowFirstNonBlank`/ `rowEnd`, resolved from the layout manager's line fragments rather than from the line table. Details that matter: - They keep their own remembered column (`preferredVisualColumn`), separate from `j`/`k`'s. Mixing the two does not make either drift. - Exclusive, as in Vim, so `dgj` removes up to the same column of the next row rather than two whole lines. - Counts and operators work (`3gj`, `dgj`, `vgj`); a count past the end stops on the last row instead of refusing to move. - The empty line after a trailing newline has no glyphs, so the layout manager would answer with the row above it. `j` reaches that line, so these do too. - When nothing wraps, every visual row is a logical line and `gj` is exactly `j` — the user never has to think about which one to press. - No text view, no layout, or an empty buffer means "cannot move", never a silent fall back to logical lines, which would move the caret somewhere the user did not ask for. Tested through the real editor view with a narrow monospaced text container so the sample paragraph genuinely wraps; the expected positions come from the layout's own line fragments, so the assertions check the motions against the layout rather than against hard-coded pixel guesses. Implementation-Agent: claude-mac-lsp Commit-Executor: claude-mac-lsp Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Xd5Hmwh5GHNTiAmHUJ1MZu
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.
Line wrapping defaults on, so a wrapped paragraph is one logical line spread over many screen rows.
jmoves a line, which means it leaps over the whole paragraph and the caret vanishes from where the user was looking. Vim's answer isgj/gk, and they were missing.MotiongainsvisualDown/visualUpandrowStart/rowFirstNonBlank/rowEnd, resolved from the layout manager's line fragments rather than from the line table.Details that matter
preferredVisualColumnis counted from the start of the visual row, independent ofj/k's logicalpreferredColumn. Mixing the two does not make either drift.dgjremoves up to the same column of the next row rather than two whole lines.3gj,dgj,vgj. A count past the end stops on the last row instead of refusing to move.jreaches that line, so these do too.gjisjwhen nothing wraps — every visual row is then a logical line, so the user never has to think about which one to press.Also
g0/g^/g$— the ends of the visual row — since they are the natural companions and the same machinery.Tests
10 new cases driven through the real editor view with a narrow monospaced text container so the sample paragraph genuinely wraps. The expected positions come from the layout's own line fragments, so the assertions check the motions against the layout rather than against hard-coded pixel guesses. One of them asserts the gap this closes directly: plain
jleaves the paragraph,gjdoes not.docs/user/gui.mdupdated.🤖 Generated with Claude Code
https://claude.ai/code/session_01Xd5Hmwh5GHNTiAmHUJ1MZu