Repository navigation
Fix db, dB and cb deleting the character under the cursor - #182
Merged
Merged
Conversation
The b and B motions are exclusive in Vim, but the operator selection was right-inclusive, so the character under the cursor was removed along with the word before it. Select the range right-exclusively instead, and correct the gu, gU and g~ backward-word tests that encoded the old behavior. Fixes unstablebuild#181 Signed-off-by: drakeo338 <[email protected]>
|
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
ernestrc
reviewed
Oct 7, 2026
| after = vi.cursor.CursorAtScroll() | ||
| } | ||
| // b is exclusive, so the character under the cursor survives. | ||
| vi.cursor.SelectRange(after, before) |
Contributor
There was a problem hiding this comment.
After f/t/F/T, the b key is the character to find, not a word motion. The w/W
case already checks for this (if prevMode == moveNone), but the b/B
case doesn't.
ernestrc
reviewed
Oct 7, 2026
ernestrc
left a comment
Contributor
There was a problem hiding this comment.
Thanks for taking this! Just a small amend.
With an operator pending, the b/B operator selection ran even when the key was the target of f, t, F or T, so dfb and dtb were handled as a backward word motion. Skip it in that case, as the w/W case already does, and add tests for fb, tb, Fb, Tb and fB. Signed-off-by: drakeo338 <[email protected]>
Contributor
Author
|
Pushed a follow-up: b/B now has the same prevMode guard as w/W, with tests for dfb, dtb, dFb, dTb and dfB. |
ernestrc
approved these changes
Oct 7, 2026
ernestrc
enabled auto-merge (rebase)
October 7, 2026 12:53
ernestrc
disabled auto-merge
October 7, 2026 12:53
ernestrc
enabled auto-merge (squash)
October 7, 2026 12:55
ernestrc
added a commit
that referenced
this pull request
Oct 11, 2026
After #182 and #185, a differential run against Vim 9.1 still showed 109 operator mismatches. handleMetaNormal anchored every operator at the cursor and treated every motion end as inclusive, so Vim's :h exclusive and :h linewise rules, its register semantics and where it leaves the cursor were not modelled: dh deleted the character under the cursor, db joined lines, and gU overwrote the unnamed register. Signed-off-by: ernestrc <[email protected]>
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
db,dBandcbremoved the character under the cursor along with the word beforeit. In Vim
bandBare exclusive motions, so that character should stay. The vihandler's operator selections are right-inclusive, so after the extra
MoveLeftStartWordin
handleMetaNormalI now refresh the end position and select the range withSelectRange(after, before), which leaves the cursor character out.The
gu,gUandg~backward-word tests (Wgub,WguB,WgUb,WgUB,Wg~b)encoded the old behavior, so I corrected their expectations. I also added a test for
db,dBandcbon a single line. I checked the same-line results against Vim 9.I did not add cases for
bacross a line break.Fixes #181
Authorship