Fix editing keyboard shortcuts in integrated browser #286765
Closed
+165
−10
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.
Keyboard shortcuts for editing operations (Cmd+C/V/X/Z/A) were not working in the integrated browser. Only mouse-driven Edit menu actions worked.
Root Cause
The integrated browser uses Electron's BrowserView, which intercepts keyboard events and forwards them to VS Code's keybinding system. However, editing commands had no handlers to forward these back to the browser's webContents.
Changes
Added editing command methods across the browser view stack:
IBrowserViewService/IBrowserViewMainService- service layer interface and implementationIBrowserViewModel/BrowserViewModel- workbench model interface and implementationBrowserView(electron-main) - calls nativewebContentsmethods:copy(),paste(),cut(),undo(),redo(),selectAll()BrowserEditor- exposes methods to contribution layerCommand interception in
browserView.contribution.ts:overrideCommandForBrowser()function (mirrors webview pattern)UndoCommand,RedoCommand,SelectAllCommand,CopyAction,PasteAction,CutActionwhen browser editor is focusedredirectCommandToBrowser()functionSupported Commands
Flow
This follows the exact pattern used by webviews for editing operations.
Original prompt
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.