zed/crates/vim/test_data/test_change_w.json
davidhi7 3fc012ef4b
vim: Fix cw with count greater than 1 not preserving whitespace correctly (#56585)
In vim, `c {count} w` diverges from the default `w` motion behavior: For
change operations, the `w` motion will be treated like the `e` motion if
the cursor is on a word, preserving whitespace after the N-th word. In
zed, this special case was only implemented for a count of 1, falling
back to incorrectly using the `w` motion if the count is greater than 1.

This PR generalizes this implementation to handle this special case for
any count.

Self-Review Checklist:

- [x] I've reviewed my own diff for quality, security, and reliability
- [x] Unsafe blocks (if any) have justifying comments
- [x] The content is consistent with the [UI/UX
checklist](https://github.com/zed-industries/zed/blob/main/CONTRIBUTING.md#uiux-checklist)
- [x] Tests cover the new/changed behavior
- [x] Performance impact has been considered and is acceptable

Closes #56563.

Release Notes:

- Fixed: vim `cw` with count greater than 1 not preserving whitespace
correctly

---------

Co-authored-by: dino <dinojoaocosta@gmail.com>
2026-06-18 14:50:31 +00:00

56 lines
1.4 KiB
JSON

{"Put":{"state":"Teˇst"}}
{"Key":"c"}
{"Key":"w"}
{"Get":{"state":"Teˇ","mode":"Insert"}}
{"Put":{"state":"Tˇest test"}}
{"Key":"c"}
{"Key":"w"}
{"Get":{"state":"Tˇ test","mode":"Insert"}}
{"Put":{"state":"Testˇ test"}}
{"Key":"c"}
{"Key":"w"}
{"Get":{"state":"Testˇtest","mode":"Insert"}}
{"Put":{"state":"Tesˇt test"}}
{"Key":"c"}
{"Key":"w"}
{"Get":{"state":"Tesˇ test","mode":"Insert"}}
{"Put":{"state":"Test teˇst\ntest"}}
{"Key":"c"}
{"Key":"w"}
{"Get":{"state":"Test teˇ\ntest","mode":"Insert"}}
{"Put":{"state":"Test tesˇt\ntest"}}
{"Key":"c"}
{"Key":"w"}
{"Get":{"state":"Test tesˇ\ntest","mode":"Insert"}}
{"Put":{"state":"Test test\nˇ\ntest"}}
{"Key":"c"}
{"Key":"w"}
{"Get":{"state":"Test test\nˇ\ntest","mode":"Insert"}}
{"Put":{"state":"Test teˇst-test test"}}
{"Key":"c"}
{"Key":"shift-w"}
{"Get":{"state":"Test teˇ test","mode":"Insert"}}
{"Put":{"state":"tesˇt-test"}}
{"Key":"c"}
{"Key":"w"}
{"Get":{"state":"tesˇ-test","mode":"Insert"}}
{"Put":{"state":"ˇTest test test"}}
{"Key":"c"}
{"Key":"2"}
{"Key":"w"}
{"Get":{"state":"ˇ test","mode":"Insert"}}
{"Put":{"state":"Tˇest test test"}}
{"Key":"c"}
{"Key":"2"}
{"Key":"w"}
{"Get":{"state":"Tˇ test","mode":"Insert"}}
{"Put":{"state":"tesˇt-test"}}
{"Key":"c"}
{"Key":"2"}
{"Key":"w"}
{"Get":{"state":"tesˇtest","mode":"Insert"}}
{"Put":{"state":"Test teˇst-test test Test"}}
{"Key":"c"}
{"Key":"2"}
{"Key":"shift-w"}
{"Get":{"state":"Test teˇ Test","mode":"Insert"}}