Repository navigation
fix(desktop): route undo/redo to CodeMirror in source code mode - #4752
Merged
Merged
Conversation
The Edit > Undo/Redo menu items and Cmd/Ctrl+Z dispatch through mt::editor-edit-action -> bus undo/redo. Only editor.vue subscribed and called the muya (WYSIWYG) engine's undo/redo, which is invisible while source code mode is active, so undo did nothing in source mode. sourceCode.vue now subscribes to the same bus events and runs CodeMirror's undo/redo command, mirroring the existing selectAll routing; editor.vue's handlers bail out while sourceCode is active so the hidden engine history is left untouched. Verified RED->GREEN with an e2e test against the built app. Fixes #781 Co-Authored-By: Claude Opus 4.8 (1M context) <[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.
Summary
Undo/redo did nothing while in Source Code mode.
The Edit › Undo/Redo menu items and Cmd/Ctrl+Z dispatch through
mt::editor-edit-action→ busundo/redo. Onlyeditor.vuesubscribed, and it called the muya (WYSIWYG) engine'sundo()/redo()— invisible while source code mode is active and the muya editor is hidden — so undo appeared to do nothing.sourceCode.vuenow subscribes to the same bus events and runs CodeMirror'sundo/redocommand, mirroring the existingselectAllrouting.editor.vue's handlers bail out whilesourceCodeis active, so the hidden engine's history is left untouched.Verification
Added an e2e test (
test/e2e/issue-781-source-undo.spec.ts) that, in source mode, types into the live CodeMirror instance, triggers undo through the same IPC the menu uses, and asserts the edit reverts (and redo re-applies it). Confirmed RED→GREEN against the built app:Lint + typecheck clean.
Fixes #781