vim: Ensure paragraph motions use empty and not blank lines#47734
vim: Ensure paragraph motions use empty and not blank lines#47734dinocosta merged 2 commits intozed-industries:mainfrom
Conversation
3facde2 to
c2b7188
Compare
|
Although I understand the intent to match vim's documented behavior for It's also worth noting that even within the vim community, this behavior has been vim/vim#222, with plugins like Would it be possible to either:
This would preserve vim compatibility for those who need it while avoiding regression for other users. |
Addresses feedback from zed-industries#47734: the previous change affected all users, but the stricter "empty line only" paragraph behavior (per vim's :help paragraph) should only apply in vim mode. - Revert editor's paragraph functions to use is_line_blank() (whitespace lines count as boundaries for non-vim users) - Add vim-specific paragraph_backwards/paragraph_forwards that use line_len() == 0 (only truly empty lines are boundaries) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
|
Thanks for pointing this out—you're right, I should have considered non-vim users. I've opened #48024 which applies the stricter behavior only in vim mode, per your first suggestion. |
Addresses feedback from zed-industries#47734: the previous change affected all users, but the stricter "empty line only" paragraph behavior (per vim's :help paragraph) should only apply in vim mode. - Revert editor's paragraph functions to use is_line_blank() (whitespace lines count as boundaries for non-vim users) - Add vim-specific paragraph_backwards/paragraph_forwards that use line_len() == 0 (only truly empty lines are boundaries) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Addresses feedback from zed-industries#47734: the previous change affected all users, but the stricter "empty line only" paragraph behavior (per vim's :help paragraph) should only apply in vim mode. - Revert editor's paragraph functions to use is_line_blank() (whitespace lines count as boundaries for non-vim users) - Add vim-specific paragraph_backwards/paragraph_forwards that use line_len() == 0 (only truly empty lines are boundaries) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Reverts the editor's paragraph navigation behavior that was changed in #47734. Whitespace-only lines are now treated as paragraph boundaries again for non-vim mode users. Vim mode retains its own implementation where only truly empty lines are paragraph boundaries. Release Notes: - Fixed editor paragraph navigation to treat whitespace-only lines as paragraph boundaries again --------- Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com> Co-authored-by: dino <dinojoaocosta@gmail.com>
Reverts the editor's paragraph navigation behavior that was changed in #47734. Whitespace-only lines are now treated as paragraph boundaries again for non-vim mode users. Vim mode retains its own implementation where only truly empty lines are paragraph boundaries. Release Notes: - Fixed editor paragraph navigation to treat whitespace-only lines as paragraph boundaries again --------- Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com> Co-authored-by: dino <dinojoaocosta@gmail.com>
Summary
Fixes #36171
The
}and{paragraph motions now correctly treat only truly empty lines (zero characters) as paragraph boundaries, matching vim's documented behavior. Whitespace-only lines are no longer treated as boundaries.The problem
In vim mode, pressing
}would stop at lines containing only whitespace (spaces, tabs). According to vim's:help paragraph:An "empty" line in vim terminology has zero characters, not whitespace-only.
The fix
Changed
start_of_paragraph()andend_of_paragraph()ineditor/src/movement.rsto checkline_len() == 0instead ofis_line_blank().Note: This change does NOT affect the
ap/iptext objects. Per vim's:help ap, those DO treat whitespace-only lines as boundaries, which is the existing (correct) behavior invim/src/object.rs.Test plan
test_paragraph_motion_with_whitespace_linesusingNeovimBackedTestContexttest_start_end_of_paragraphstill passesRelease Notes:
}and{) to correctly ignore whitespace-only lines