fix(session-ui): add CM6 editing shortcuts (undo/redo/copy/cut/paste/select-all) to Files Changed editor - #304
Merged
Conversation
…ions Add @codemirror/commands dependency and wire history(), defaultKeymap, historyKeymap, and bracketMatching() into the diff editor. - history() in editableExtensions (only when readOnly is false) - keymap + bracketMatching in baseExtensions (shared by all panes) Part of #302
updateModified and updateOriginal use addToHistory.of(false), which the new history() extension respects. These tests confirm the invariant. Part of #302
Use isolateHistory.of('full') on the revert dispatch so it always
creates its own undo group. Cmd+Z after revert now restores the
pre-revert edits. Updated docstrings to match.
Part of #302
|
Important
This repository does not receive automatic reviews because it has fewer than 10 stars. ⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Team Run ID: Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Add CLIPBOARD_EDITOR_SELECTOR for data-amc-clipboard='codemirror'. The global handler returns early (no preventDefault) for undo/redo/ select-all when the target is inside a CM6 editor, letting CM6's own keymap handle them. Clipboard chords (C/X/V) still bridge. Part of #302
Inside a CM6 editor, cut deletion uses execCommand('delete') instead
of range.deleteContents() so CM6's mutation observer creates a proper
undo-tracked transaction. Non-CM6 contenteditable targets keep the
existing range.deleteContents() + dispatchInput('deleteByCut') path.
Part of #302
…tion Add data-amc-clipboard='codemirror' to the EditableDiffView container div so global-clipboard.ts recognizes it and delegates Z/Y/A to CM6. Part of #302
jeonghun-jj-lee
marked this pull request as ready for review
September 6, 2026 20:23
…faults CM6's built-in default uses a 5-class child-combinator selector for .cm-selectionBackground with hardcoded colors (#233 dark, #d7d4f0 light). Our theme's lower-specificity descendant selector lost, making selections invisible in dark mode. Use matching child-combinator depth so our CSS variable (--v2-background-bg-layer-03) wins. Part of #302
… handler createDiffEditor attaches getSelectedText() and cutSelectedText() on the parent element so the global clipboard handler can read from CM6's document model without importing @codemirror packages. Cleaned up on destroy(). Part of #302
When copying or cutting inside a CM6 editor, the global clipboard handler now reads from the __amcEditor bridge (which uses state.sliceDoc) instead of window.getSelection().toString(). This fixes two bugs: - Unified mode: DOM selection included deleted-line decoration widgets - ReadOnly mode: DOM selection might not be synced by CM6 Part of #302
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 #302
Adds standard editing shortcuts to the CodeMirror 6 diff editor in the Files Changed tab.
Changes
session-ui@codemirror/commands6.11.0 dependencyhistory(),defaultKeymap,historyKeymap,bracketMatching()into the diff editorhistory()lives ineditableExtensions(only whenreadOnly: false)isolateHistory.of('full')so it's always undoable via Cmd+Z (D7)revert()docstrings (said 'clear undo history' — now correct)data-amc-clipboard="codemirror"on the container div.cm-selectionBackgroundCSS specificity to beat CM6's built-in defaults (#233dark /#d7d4f0light)__amcEditorbridge on the container element withgetSelectedText()/cutSelectedText()that read from CM6's document model (state.sliceDoc), not the DOMappCLIPBOARD_EDITOR_SELECTORfor the CM6 opt-out contractpreventDefault)extractSelectionusesexecCommand('delete')for CM6 cut targets__amcEditorbridge instead ofwindow.getSelection().toString()— fixes garbled copy in unified mode and empty copy in readOnly modeTesting
editable-diff-view.test.ts(13 new): undo/redo, external update exclusion, revert undoability, selection highlight specificity,__amcEditorbridge (stash/read/cut/readOnly/cleanup)global-clipboard.test.ts(12 new): CM6 delegation for Z/Shift+Z/Y/A, clipboard bridging for C/V,extractSelectioncut behavior,__amcEditorbridge copy/cut/no-selection