vim: Fix dot repeat after macro replay not capturing insertion text#57684
Merged
smitbarmase merged 2 commits intoMay 27, 2026
Merged
Conversation
…ed-industries#47251) Fix by calling `observe_insertion` explicitly in the `ReplayableAction::Insertion` branch of `Replayer::next`.
smitbarmase
requested changes
May 27, 2026
smitbarmase
left a comment
Member
There was a problem hiding this comment.
Thanks, but I don't think this is the right way to approach this. Consider this test:
cx.set_state("ˇfoo foo", Mode::Normal);
cx.simulate_keystrokes("q l c f o x escape q");
cx.assert_state("ˇxo foo", Mode::Normal);
cx.simulate_keystrokes("w @ l");
cx.assert_state("xo ˇxo", Mode::Normal);
cx.simulate_keystrokes(".");
cx.assert_state("xo xˇ", Mode::Normal);With this PR, the final state becomes xo ox. The replay path treats the o from f o as inserted text, so when . runs it inserts an extra o.
Contributor
smitbarmase
approved these changes
May 27, 2026
smitbarmase
left a comment
Member
There was a problem hiding this comment.
Okay, I made a fix. Now replay_insert_event emits InputHandled when input is enabled, and the existing early return when input is disabled covers the Normal mode case, which I found was broken.
We already call observe_insertion from the InputHandled path here:
Line 1137 in 2dfdf90
Contributor
Author
|
I'm sorry for missing that. Thanks for catching it and pushing the fix. |
TomPlanche
pushed a commit
to TomPlanche/zed
that referenced
this pull request
Jun 2, 2026
…ed-industries#57684) Closes zed-industries#47251 Fix dot (`.`) repeat not correctly repeating the last change after replaying a macro (`@register`) ([zed-industries#47251](zed-industries#47251)) When replaying a macro that contains text insertions, `replay_insert_event` calls `handle_input` directly and never emits `InputHandled`, so the `observe_insertion` subscription never fires. This left the dot register stale — `.` after `@register` would repeat an earlier change instead of the last one made by the macro. Fix by calling `observe_insertion` explicitly in the `ReplayableAction::Insertion` branch of `Replayer::next`. Release Notes: - Fixed dot (`.`) repeat not repeating the last change made by a macro (`@register`). --------- Co-authored-by: Smit Barmase <heysmitbarmase@gmail.com>
This was referenced Jun 3, 2026
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.
Closes #47251
Fix dot (
.) repeat not correctly repeating the last change after replaying a macro (@register) (#47251)When replaying a macro that contains text insertions,
replay_insert_eventcallshandle_inputdirectly and never emitsInputHandled, so theobserve_insertionsubscription never fires. This left the dot register stale —.after@registerwould repeat an earlier change instead of the last one made by the macro.Fix by calling
observe_insertionexplicitly in theReplayableAction::Insertionbranch ofReplayer::next.Release Notes:
.) repeat not repeating the last change made by a macro (@register).