Skip to content

feat(motions): add bw#126

Open
yuu-ux wants to merge 4 commits into
glide-browser:mainfrom
yuu-ux:feat/bw_command
Open

feat(motions): add bw#126
yuu-ux wants to merge 4 commits into
glide-browser:mainfrom
yuu-ux:feat/bw_command

Conversation

@yuu-ux
Copy link
Copy Markdown

@yuu-ux yuu-ux commented Nov 26, 2025

overview

Added key sequence support for dw.

Potential Issues

In nvim, dw on hello\nworld deletes only hello (it does not delete the newline). In this PR, however, the current implementation deletes hello\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.

@yuu-ux yuu-ux changed the title feat(motion): add bw command feat(motions): add bw Dec 22, 2025
@yuu-ux yuu-ux marked this pull request as ready for review December 22, 2025 04:02
Copy link
Copy Markdown
Member

@RobertCraigie RobertCraigie left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 :)

https://glide.zulipchat.com

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

await test_motion("w", 8, "w", "todo");

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) {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

for the EOL case in particular, did you try the is_eol helper?

export function is_eol(editor: Editor): boolean {

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Comment on lines +134 to +139
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");
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Suggested change
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");

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for your comment.
I have adjusted the test code, so please check it again.
d9d145c

@yuu-ux yuu-ux requested a review from RobertCraigie February 8, 2026 05:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants