Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Jan 9, 2026

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 implementation
  • IBrowserViewModel / BrowserViewModel - workbench model interface and implementation
  • BrowserView (electron-main) - calls native webContents methods: copy(), paste(), cut(), undo(), redo(), selectAll()
  • BrowserEditor - exposes methods to contribution layer

Command interception in browserView.contribution.ts:

  • Added overrideCommandForBrowser() function (mirrors webview pattern)
  • Intercepts UndoCommand, RedoCommand, SelectAllCommand, CopyAction, PasteAction, CutAction when browser editor is focused
  • Directly invokes corresponding browser editor methods
  • Removed unused redirectCommandToBrowser() function

Supported Commands

  • Cmd+Z / Ctrl+Z: Undo
  • Cmd+Shift+Z / Ctrl+Y: Redo
  • Cmd+A / Ctrl+A: Select All
  • Cmd+C / Ctrl+C: Copy
  • Cmd+V / Ctrl+V: Paste
  • Cmd+X / Ctrl+X: Cut

Flow

Cmd+C/V/X/Z/A pressed → BrowserView intercepts → Sends to VS Code keybinding service
→ overrideCommandForBrowser intercepts → Calls browserEditor method
→ Forwards through model/service layers → Calls webContents method
→ Executes in browser context ✓

This follows the exact pattern used by webviews for editing operations.

Original prompt

This section details on the original issue you should resolve

<issue_title>Integrated Browser: copy/paste keyboard shortcuts not working</issue_title>
<issue_description>- VS Code Version: 1.109.0-insider

  • OS Version: macOS Tahoe 26.2

Steps to Reproduce:

  1. In command palette, run: "Browser: Open Integrated Browser"
  2. Open any website that has text and a textbox, such as wikipedia.org
  3. 🐛 Try to copy the text using Ctrl/Cmd + C and paste it into the textbox using Ctrl/Cmd + V. Neither copy nor paste work.

Expected behavior:
Copy/Paste shortcuts should work as expected

Note:
Copy/Paste works only if you do it from VS Code's Edit menu via mouse clicks</issue_description>

Comments on the Issue (you are @copilot in this section)


💡 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.

Copilot AI changed the title [WIP] Fix copy/paste keyboard shortcuts in integrated browser Fix copy/paste/cut keyboard shortcuts in integrated browser Jan 9, 2026
Copilot AI requested a review from jruales January 9, 2026 16:07
Copilot stopped work on behalf of jruales due to an error January 9, 2026 16:42
Copilot stopped work on behalf of jruales due to an error January 9, 2026 16:44
});
}

redirectCommandToBrowser(UndoCommand);
Copy link
Contributor

Choose a reason for hiding this comment

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

@copilot let's do the same for undo, redo, and select all here. And remove the unused redirectCommandToBrowser.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done in 8aa0bb4. Added undo, redo, and selectAll methods across the browser view stack and removed the unused redirectCommandToBrowser function. All commands now use overrideCommandForBrowser consistently with the webview pattern.

Copilot AI changed the title Fix copy/paste/cut keyboard shortcuts in integrated browser Fix editing keyboard shortcuts in integrated browser Jan 9, 2026
Copilot AI requested a review from kycutler January 9, 2026 19:55
@jruales jruales closed this Jan 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Integrated Browser: copy/paste keyboard shortcuts not working

3 participants