feat(motions): add bw#126
Conversation
0d3527e to
724dd67
Compare
f68a2fd to
21b6158
Compare
21b6158 to
5f6d71a
Compare
RobertCraigie
left a comment
There was a problem hiding this comment.
Thanks for working on this! The tests are great :)
I wasn’t able to resolve it in a reasonable time. So I’m sending this PR with the simpler behavior for now.
If strict nvim compatibility is required, I can follow up and fix the newline behavior.
Since I'm weak in English, I'm using a translation app. Please let me know if there are any unclear English sentences.
I want to be clear that I have no expectations for you to figure everything out on your own! Contributing should be a very collaborative process, so if you ever get stuck on something please reach out!
There is a Zulip chat now, and I'll probably be more responsive there over discord, and there's a (small, right now) chance other people could response as well :)
r.e. strict vim matching, generally I do try to make it match exactly, but in some cases it is tricky, so I leave todo tests with the correct behaviour lying around
also your english has been great, I would've thought you were a native speaker!
| break; | ||
| } | ||
| forward_word(editor, false, "visual"); | ||
| if (selection_has_cls_white_space(editor) || text_obj.cls(current_char(editor)) !== starting_cls) { |
There was a problem hiding this comment.
for what its worth, I'm surprised the text_obj.cls(current_char(editor)) !== starting_cls check didn't fix the hello\nworld case you mention in the description?
There was a problem hiding this comment.
for the EOL case in particular, did you try the is_eol helper?
There was a problem hiding this comment.
Thank you for your comment. Sorry for the delay, but I have also been able to handle cases including line breaks, so could you please check it?
295d46f
| await set_selection(5); | ||
| await test_edit("dw", "helloworld", 5, "w"); | ||
|
|
||
| await set_text("h h h", "dw deletes a single-letter word + following space"); | ||
| await set_selection(2); | ||
| await test_edit("dw", "h h", 2, "h"); |
There was a problem hiding this comment.
nit: you can also set the expected char to make the test easier to read, and I also like to avoid duplicate chars for the same reason
| await set_selection(5); | |
| await test_edit("dw", "helloworld", 5, "w"); | |
| await set_text("h h h", "dw deletes a single-letter word + following space"); | |
| await set_selection(2); | |
| await test_edit("dw", "h h", 2, "h"); | |
| await set_selection(5, "?"); | |
| await test_edit("dw", "helloworld", 5, "w"); | |
| await set_text("h j k", "dw deletes a single-letter word + following space"); | |
| await set_selection(2, "j"); | |
| await test_edit("dw", "h k", 2, "k"); |
There was a problem hiding this comment.
Thank you for your comment.
I have adjusted the test code, so please check it again.
d9d145c
overview
Added key sequence support for dw.
Potential Issues
In nvim,
dwonhello\nworlddeletes onlyhello(it does not delete the newline). In this PR, however, the current implementation deleteshello\n.I originally tried to match nvim by adjusting the selection with conditional logic: if the selected text contained a newline, move the selection end back to just before the newline; if it contained tabs/spaces, move it to the end of the whitespace run. With that approach, I hit a bug where deletion did not run at all when the selected range contained a newline, and I wasn’t able to resolve it in a reasonable time. So I’m sending this PR with the simpler behavior for now.
If strict nvim compatibility is required, I can follow up and fix the newline behavior.
Since I'm weak in English, I'm using a translation app. Please let me know if there are any unclear English sentences.