vim: Fix subword motion near end of line#45908
Merged
dinocosta merged 4 commits intozed-industries:mainfrom Jan 14, 2026
Merged
vim: Fix subword motion near end of line#45908dinocosta merged 4 commits intozed-industries:mainfrom
dinocosta merged 4 commits intozed-industries:mainfrom
Conversation
Member
|
Holding off on reviewing this until #45341 (review) is resolved, as that might impact these changes 🔍 |
Member
rtfeldman
pushed a commit
that referenced
this pull request
Jan 14, 2026
Fixes subword motion incorrectly jumping to next line when near end of line. Updates boundary detection to use exclusive boundaries with need_next_char parameter, matching regular word motion behavior. Refactors word and subword motion to share boundary detection logic. Closes #17780 Release Notes: - Fixed subword motion incorrectly jumping to the next line when near the end of a line --------- Co-authored-by: dino <dinojoaocosta@gmail.com>
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.
Closes #17780
The main issue that is fixed here: the boundary detection logic currently excludes newlines due to
!at_newline:But removing
&& !at_newlinereveals a secondary issue with the backtracking implemented in the subword motion:If
new_pointrepresents the newline, an invalid position, clipping the point with a left bias causes a one-character backtrack to match a valid position. Then in the next statement we backtrack again. Because of this the cursor no longer moves once it reaches a newline.Here the fix is to use the same approach as in the regular word motion: find an exclusive boundary instead of an inclusive one in the first place, then we don't need backtracking. The
need_next_charlogic, also copied from the regular motion implementation, is needed to ensure that motions that don't allow crossing line breaks still make some progress at newlines.This whole fix is self-contained in the first commit. The second commit is a refactor that makes both motions use the same implementation (with an
is_boundarypredicate), since they are now so close. This way it'll be easier to keep them in sync.Release Notes: