You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Thanks for picking this up, @paulluis-roehl! The tests fit right in with the existing ones.
I tried a few edge cases on the branch and found some spots where it doesn't match Vim:
dW on the last word of a line joins it with the next line. With foo bar\n baz and the cursor on bar, dW gives foo baz. W treats the newline and the indent as normal spaces and skips them. Vim stops at the end of the line, so you'd get foo \n baz.
dE at the very end of the text deletes the last character. With foo and the cursor after the last o (offset 3), dE deletes the o. wordMotion returns len - 1, which is smaller than the cursor, so Math.min(offset, target) flips the range. Vim does nothing here. Same for yE.
cW should work like cE. With foo.bar baz and the cursor at 0, cW also deletes the space after foo.bar, so typing x gives xbaz. Vim keeps the space and gives x baz. The test "cW deletes from cursor to start of next WORD" would need to change too.
Vim treats an empty line as a WORD. With foo\n\nbar, W from the start jumps to bar, but Vim stops on the empty line first. So 2W goes one too far for each blank line.
Visual B sends the range backwards, e.g. selectRange { start: 20, end: 12 }. I'm not sure setSelectionInclusive handles start > end, and I haven't tried it in OpenCode yet. Sorting the two with Math.min/Math.max first would be safe either way.
A couple of smaller things:
The early returns (dW at the end of the text, dB at the start) and counts like 2dW / d2B don't have tests yet.
The E case is almost a copy of endOfWord (the TODO says so). Not a blocker, but sharing one loop would mean less to keep in sync.
Thanks for the review! Before I have a go at them, I have some more questions:
What does "at the very end of text" mean in vim? As far as I know, in vim the cursor is always on a character, while in this plugin the cursor can be right behind the last character (presumably leading to the issue with dE). Keeping to vim would mean that both dE and de should delete the last character.
You say cW deletes the space after foo.bar in foo.bar baz, which is unintended behaviour. Your current cw has the same behaviour however (for foobar baz), inherited from the opencode command input.delete.word.forward. Which one should I keep to? (In particular, I am not entirely sure in how far the opencode commands adhere to standard vim rules in terms of whitespace, word delimiters and so on. We might have more control if we abstained from used them fully, in some future version)
Is it fine to put the B range fix (i.e. explicitly sorting min/max) directly into the index.ts into the case "selectRange":? This seems like the best way to handle this for any situation that may require inverted ranges
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
W,B, andEmotions that keep punctuation and URLs together.etest cases and assertion style.Closes #88
Validation