Skip to content

Conversation

@DanTup
Copy link
Contributor

@DanTup DanTup commented Oct 16, 2025

On macOS, short-cut keys like Cmd+C, Cmd+V don't work in embedded iframes. This happens because VS Code calls setIgnoreMenuShortcuts(true) and disables the OS/browser functionality for these actions. For the top-level webviews, it handles keypresses, passes them up to VS Code, and VS Code then passes back down commands for copy/paste/etc.

However for our nested iframes, this keypress handling (and command passing) does not occur.

I wasn't able to find any way to fix this inside VS Code (it can't reach into our iframes because they're a different origin) but I found that we can simulate what it's doing itself. I thought I'd tried this in the past and determined this wouldn't work, however it seems to work fine today (maybe I was trying to handle the Copy/Paste events rather than the keys? 🤔)

I can't write automated tests for this because we need to verify the actual behaviour of pressing keys, but I've tested on both my Mac and Windows (it already worked on Windows and doesn't need this, but I've left this code to run for all platforms in case there is a difference between using VS Code's native menus vs not) by using dart.customDevTools and in both of them, I can copy/paste/select-all/undo.

Fixes Dart-Code/Dart-Code#3488
Fixes #7253
Fixes #9435
See #8190 (I don't know if we still want to do other work here)
See microsoft/vscode#129178 (comment)

cc @elliette

@DanTup DanTup requested a review from a team as a code owner October 16, 2025 15:13
@DanTup DanTup requested review from elliette and removed request for a team October 16, 2025 15:13
Copy link
Member

@elliette elliette left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One question but LGTM!

I'm going to file a bug for the flaky integration tests (re-running them now).

@DanTup DanTup added the autosubmit Merge PR when tree becomes green via auto submit App label Oct 17, 2025
@auto-submit auto-submit bot merged commit fb4fa1f into flutter:master Oct 17, 2025
36 checks passed
@DanTup DanTup deleted the vs-code-copy-paste-fix branch October 19, 2025 19:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

autosubmit Merge PR when tree becomes green via auto submit App

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Can't paste text in some inspector textField Cannot paste content to input field Can't copy text from DevTools with Cmd+C

2 participants