feat(undo): reconcile native + CodeMirror undo via one app-level handler#10167
Open
jackkav wants to merge 1 commit into
Open
feat(undo): reconcile native + CodeMirror undo via one app-level handler#10167jackkav wants to merge 1 commit into
jackkav wants to merge 1 commit into
Conversation
The Edit menu's Undo/Redo used role: 'undo'/'redo', driving only the native webContents stack. On macOS the menu accelerator swallows Cmd+Z before CodeMirror's keymap, so CodeMirror surfaces had no working undo — two competing stacks with the native one always winning and doing nothing useful for CM. Menu Undo/Redo now send edit:undo/edit:redo to the focused window; a single renderer handler (editor-undo.ts, wired in renderer-listeners.ts) routes by focus: CodeMirror surfaces drive cm.undo()/redo(); everything else replays the native execCommand, preserving prior plain-input behaviour. No double-fire: the accelerator still keeps CM's own keymap from firing independently.
✅ Circular References ReportGenerated at: 2026-06-26T08:18:44.401Z Summary
Click to view all circular references in PR (9)Click to view all circular references in base branch (9)Analysis✅ No Change: This PR does not introduce or remove any circular references. This report was generated automatically by comparing against the |
ryan-willis
approved these changes
Jun 26, 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.
What
Follow-up to #10152 (opportunity # 4 in
docs/undo-redo-baseline.md). Reconciles the two competing undo stacks through a single app-level handler.Why
The Edit menu's Undo/Redo used
role: 'undo'/'redo', which drive only Electron's nativewebContents.undo()/redo()stack. On macOS the menu accelerator swallowsCmd+Zbefore CodeMirror's own keymap can act on it — so in CodeMirror surfacesCmd+Zdid nothing useful (the native stack doesn't understand CodeMirror's document). Two stacks, native always wins, CodeMirror inert.How
role; theysend('edit:undo')/send('edit:redo')to the focused window (labels + accelerators unchanged).editor-undo.ts, wired inrenderer-listeners.ts— routes by focus:.CodeMirrorwrapper →cm.undo()/redo()(CodeMirror's own history)document.execCommand('undo'/'redo'), replicating exactly what the native role did for plain inputs.No double-fire: the menu accelerator still prevents CodeMirror's keymap from firing independently (confirmed by the original baseline probe, where
Cmd+Zon the URL bar was inert).Test
editor-undo.test.ts(3 cases): CodeMirror focus drivescmhistory and does not touch the native stack; plain input falls back toexecCommand; no-focus falls back toexecCommand.tsc+ ESLint clean (no--fix).closes INS-2877