Conversation
Capture full dispatch context in mgwrap (last_command + last_f/last_n + last_key snapshot) and re-run repeat THROUGH mgwrap, restoring key first. Fixes the 4 review findings from the dropped first attempt: selfinsert char, undo rptcount continuation, ABORT handling, numeric prefix. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Pj1ZHaD7aNhVWJ69SFKJcp
One task: mgwrap captures last_command + last_f/last_n + last_key snapshot; repeat restores key + re-runs through mgwrap; bind C-x z (cXmap 6->7). pty tests: self-insert repeats right char (xxx not xz), no-prior-command beeps, movement repeat lands correctly. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Pj1ZHaD7aNhVWJ69SFKJcp
Redo of the dropped first attempt, correctly this time. mgwrap captures the full dispatch context for each real command: last_command (replaces the static ofp), last_f/last_n (numeric prefix), and last_key (a snapshot of the invoking key sequence). repeat restores key and re-runs THROUGH mgwrap, so: - selfinsert reads the original char (x -> xxx, not xz), - undo sees rptcount++ and continues the chain (not a redo), - ABORT/FALSE stop the loop (!= TRUE), - the numeric prefix is preserved (C-u 5 C-n then C-x z moves 5). Bind C-x z (cXmap 6->7). repeat is excluded from last_command so it can't recurse. macOS 329/329. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Pj1ZHaD7aNhVWJ69SFKJcp
…rash) Whole-branch review: a C-x z recorded into a keyboard macro crashed on replay -- executemacro() calls recorded steps directly (bypassing mgwrap), so last_command stays executemacro; the recorded repeat then re-ran the whole macro and recursed to a stack overflow. Guard repeat with inmacro (like query-replace's macro guard). Add regression tests: macro-with-C-x-z replays without crashing and the editor stays responsive; and C-x z preserves the repeated command's numeric prefix (C-u 3 C-n then C-x z lands on line 7, proving n=3 wasn't dropped). Moved the def.h prototype into the kbd.c section. macOS 331/331. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Pj1ZHaD7aNhVWJ69SFKJcp
danielxvu
pushed a commit
that referenced
this pull request
Jul 6, 2026
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Pj1ZHaD7aNhVWJ69SFKJcp
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.
feat: C-x z repeats the last command (done right)
The
C-x zrepeat that was dropped from #117 for silent data corruption — reworked correctly.Approach
mgwrap(the single dispatch point) now captures the full context for each real command:last_command(replacing the oldstatic ofp),last_f/last_n(numeric prefix), andlast_key(a snapshot of the invoking key sequence).repeatrestoreskeyand re-runs the command throughmgwrapin a loop, stopping on non-TRUE, and repeating while you pressz.This fixes all four bugs the earlier review caught:
selfinsertreads its char fromkey.k_chars→ restoringkeygives the original char (x→xxx, notxz);undokeys offrptcount→ routing throughmgwrapincrements it, soC-x zafterC-x ucontinues undoing instead of reversing it;goto-line) stops the loop (!= TRUE);C-u 3 C-nthenC-x zmoves 3+3).This branch's own review caught one more
C-x zrecorded into a keyboard macro stack-overflowed on replay (executemacrore-runsrepeat, whoselast_commandis nowexecutemacro→ infinite recursion). Fixed by refusingrepeatduring macro replay (inmacro), likequery-replace's macro guard — with a regression test that records a macro containingC-x z, replays it, and asserts the editor survives and stays responsive.Tests / verification
pty: self-insert repeats the right char; undo continuation; numeric prefix preserved; macro replay no-crash; no-prior-command beeps. macOS 331/331 · TSan zero races · Alpine/musl 331/331 · legacy plain-C clean.
Based on
neomg.🤖 Generated with Claude Code
https://claude.ai/code/session_01Pj1ZHaD7aNhVWJ69SFKJcp