vim: Ensure paragraph motions use empty and not blank lines - #47734
Conversation
|
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. |
|
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. |
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>
…stries#47734) 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. Changed `start_of_paragraph()` and `end_of_paragraph()` in `editor/src/movement.rs` to check `line_len() == 0` instead of `is_line_blank()`. Note: This change does NOT affect the `ap`/`ip` text objects. Per vim's `:help ap`, those DO treat whitespace-only lines as boundaries, which is the existing (correct) behavior in `vim/src/object.rs`. Closes zed-industries#36171 Release Notes: - Fixed vim mode paragraph motions (`}` and `{`) to correctly ignore whitespace-only lines --------- Co-authored-by: dino <dinojoaocosta@gmail.com>
…8024) Reverts the editor's paragraph navigation behavior that was changed in zed-industries#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>
…stries#47734) 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. Changed `start_of_paragraph()` and `end_of_paragraph()` in `editor/src/movement.rs` to check `line_len() == 0` instead of `is_line_blank()`. Note: This change does NOT affect the `ap`/`ip` text objects. Per vim's `:help ap`, those DO treat whitespace-only lines as boundaries, which is the existing (correct) behavior in `vim/src/object.rs`. Closes zed-industries#36171 Release Notes: - Fixed vim mode paragraph motions (`}` and `{`) to correctly ignore whitespace-only lines --------- Co-authored-by: dino <dinojoaocosta@gmail.com>
…8024) Reverts the editor's paragraph navigation behavior that was changed in zed-industries#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