Fix Monaco clipboard handling in webviews - #465
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 554b81a3bf
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| editor.trigger('keyboard', 'paste', { text }); | ||
| const selections = editor.getSelections() ?? []; | ||
| editor.pushUndoStop(); | ||
| editor.executeEdits('clipboard', selections.map(selection => ({ range: selection, text }))); |
There was a problem hiding this comment.
Preserve multi-cursor paste distribution
When the clipboard was produced from multiple selections, copySelection serializes those selections as newline-separated text; with multiple cursors active, this direct edit now inserts the entire clipboard text at every cursor. Monaco's paste path previously handled the common multiCursorPaste: 'spread' case by distributing matching clipboard lines across cursors, so copying foo/bar from two cursors and pasting into two cursors now yields foo\nbar twice instead of foo and bar separately.
Useful? React with 👍 / 👎.
Replace editor.addCommand with per-editor onKeyDown interception. addCommand
registers unscoped keybindings on the singleton standalone keybinding service,
so with multiple Monaco editors mounted (formula list, preview input/output)
Ctrl+C/X/V targeted the last-created editor regardless of focus and leaked on
destroy. onKeyDown is scoped to the focused editor and disposed with it.
Restore editor.trigger('keyboard','paste',{text}) so paste keeps multi-cursor
spread and paste-on-new-line. Make the clipboard write fire-and-forget: the
host bridge is only required for read (paste) in a webview, so writes no longer
round-trip for an unused ack.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
|



Summary
Validation