fix: defer defaultPrevented check to microtask in preload-browserView (#306414)#307471
Open
maruthang wants to merge 2 commits intomicrosoft:mainfrom
Open
fix: defer defaultPrevented check to microtask in preload-browserView (#306414)#307471maruthang wants to merge 2 commits intomicrosoft:mainfrom
maruthang wants to merge 2 commits intomicrosoft:mainfrom
Conversation
CP857 was supported by the terminal but missing from document encoding support. Adds the encoding with labels 'Turkish DOS (CP 857)' / 'CP 857' and a regression test.
…microsoft#306414) Electron's isolated-world keydown listener fires before the page's main-world listeners, so event.defaultPrevented was always false when checked synchronously. Commands like Command+Shift+P and F1 on vscode.dev were being forwarded to the host window even though the page had called preventDefault(). Move the defaultPrevented check inside queueMicrotask() so it runs after all synchronous event handlers in all worlds have completed. Capture a snapshot of the event properties before the microtask to avoid reading a recycled event object. Fixes microsoft#306414
Contributor
📬 CODENOTIFYThe following users are being notified based on files changed in this PR: @kycutlerMatched files:
@jrualesMatched files:
@bpaseroMatched files:
|
kycutler
requested changes
Apr 2, 2026
Contributor
kycutler
left a comment
There was a problem hiding this comment.
This doesn't seem to work -- it looks like defaultPrevented isn't actually true within the microtask callback.
The branch is also out of date with some of the latest changes in main and contains an unrelated encoding change.
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
Fixes #306414
Bug:
Command+Shift+PandF1do not work on vscode.dev when opened in the Integrated Browser view — the shortcuts are forwarded to the host VS Code window instead of being handled by the page.Root Cause: Electron's isolated-world keydown listener (running in the preload script at worldId 999) fires before the page's main-world listeners. The synchronous
event.defaultPreventedcheck therefore always readfalse, even when vscode.dev's own listener was about to callpreventDefault(). As a result, key events were incorrectly forwarded to the host.Fix: Move the
event.defaultPreventedcheck inside aqueueMicrotask()callback. A microtask runs after all synchronous event handlers in all worlds have completed, sodefaultPreventedreflects the final value set by any page listener. A snapshot of the relevant event properties is captured synchronously (before the microtask) to avoid reading a recycled event object.Changes
src/vs/platform/browserView/electron-browser/preload-browserView.ts: Remove synchronousdefaultPreventedguard; capture event property snapshot; defer guard and IPC send intoqueueMicrotask().src/vs/platform/browserView/test/electron-main/preloadKeyForwarding.test.ts: New test file with 4 regression tests covering: (1) no forward when page callspreventDefault()forCommand+Shift+P, (2) no forward when page callspreventDefault()forF1, (3) forward fires when nopreventDefault()is called, (4) plain character keys without modifiers are not forwarded.Testing
src/vs/platform/browserView/test/electron-main/preloadKeyForwarding.test.tsthat exercise the key-forwarding logic in isolation (no Electron context required).Manual verification steps
https://vscode.devin the Integrated Browser panel.Command+Shift+P(macOS) orCtrl+Shift+P(Linux/Windows) — the vscode.dev command palette should open, not the host VS Code one.F1— the vscode.dev command palette should open.a) in a text area — it should type normally without being intercepted.