fix(motion): use 'foldedLine' cursorMove unit for j/k over folds#9940
Draft
jaidhyani wants to merge 1 commit intoVSCodeVim:masterfrom
Draft
fix(motion): use 'foldedLine' cursorMove unit for j/k over folds#9940jaidhyani wants to merge 1 commit intoVSCodeVim:masterfrom
jaidhyani wants to merge 1 commit intoVSCodeVim:masterfrom
Conversation
Use VS Code's 'foldedLine' cursorMove unit as the default movement for j/k, which moves by logical lines while treating each folded region as a single step. On VS Code versions without this unit, the command degrades to standard line movement (no regression). The existing foldfix workaround is preserved for users on unpatched VS Code. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
5fb3577 to
fa9d6e3
Compare
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
Fixes #1004.
j/kin Normal and Visual modes now skip over folded regions without unfolding them, by using the newfoldedLineunit added to VS Code's built-incursorMovecommand (microsoft/vscode#296106).Root cause
Previously,
MoveDown/MoveUpcalledposition.getDown()/position.getUp(), which returns model-space positions. If the next model line is inside a fold, VS Code interprets that as navigating into a hidden region and auto-unfolds it.The
foldfixworkaround (toggling folds off/on around the move) was fragile and had edge cases.Fix
Adds
MoveDownByFoldedLineandMoveUpByFoldedLinemotion classes that delegate tocursorMovewithby: 'foldedLine'. VS Code core handles fold detection and skipping natively, with no extension-side fold awareness needed.j/know always use these motions (except VisualBlock mode, which uses model-line movement intentionally).Changes
src/actions/motion.ts:MoveDownByFoldedLine,MoveUpByFoldedLineclasses; updatedMoveDown/MoveUpexec actionssrc/textEditor.ts: added'foldedLine'toCursorMoveByUnittypepackage.json: deprecatedvim.foldfixsetting with a message pointing to this fixDependency
Requires the
foldedLineunit to be available in the installed VS Code version (microsoft/vscode#296106). Until that ships, the settingvim.foldfixcontinues to work as a fallback for users on older VS Code versions.