-
Notifications
You must be signed in to change notification settings - Fork 30.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rework copy paste and other browser events for webviews (#101958)
Fixes #101946 Webview can currently trigger some keyboard events twice. Sequence of events: - User presses ctrl+v with a webview focused - Webview is listening to keyboard events for rebroadcast (so that we can handle normal VS code commands even when focused on webviews) - We rebroadcast the keypresses back to VS Code - The webview then triggers the standard copy behavior on its own (I believe this is either chromium or electron) - VS Code gets the ctrl+v keypress event and resolves it to the 'paste' command - The paste command triggers the paste method on the webview - This calls back into the webview content to trigger a second paste This does not happen in cases where we are using native menus, which can call `setIgnoreMenuShortcuts` to disable the browser geenrated paste event. ## The fix To fix this, I think we want to completely block the browser generate events in all cases and instead always dispatch the events through VS Code. This should ensure more consistent behavior. This PR does this by: - In the webview, add a keypress listener for copy/paste/cut and undo/redo. When we see these events, call `preventDefault` to block them but still dispatch back to VS Code - In VS Code, more the logic for triggering undo/redo, etc. on webviews out of the electron layer and into the browser layer. iframe based webviews have the exact same problem as electron based webviews, so we need to fix this issue for both of them.
- Loading branch information
Showing
6 changed files
with
106 additions
and
56 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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