Microsoft/vscode

Ctrl-P text navigation shortcut does not work inside webview on macOS

Open

#264.957 geöffnet am 3. Sept. 2025

Auf GitHub ansehen
 (1 Kommentar) (1 Reaktion) (1 zugewiesene Person)TypeScript (10.221 Forks)batch import
bughelp wantedmacoswebview

Repository-Metriken

Stars
 (74.848 Stars)
PR-Merge-Metriken
 (Durchschn. Merge 11h 43m) (1.000 gemergte PRs in 30 T)

Beschreibung

  • VS Code Version: 1.103.2 (Universal)
  • OS Version: Mac OS Sequoia 15.6.1 (24G90)

For text input controls, MacOS supports "emacs" shortcuts for cursor navigation: Ctrl-A and Ctrl-E go to the beginning and ending of a line, and Ctrl-N and Ctrl-P go to the next or previous line.

When a multi-line text input box or content-editable control is used within a webview, all of these standard keyboard shortcuts work except for Ctrl-P. This key sequence is currently swallowed by the script that VS Code injects into the iframe that hosts a webview. The specific code is in handleInnerKeydown, which calls isPrint(e). On Windows, the Ctrl-P shortcut should be suppressed because it corresponds to the "print" command. On MacOS, it should not be suppressed. The straightforward fix is to modify isPrint so it takes into consideration the current platform.

Steps to Reproduce:

  1. Create a simple VS Code extension with a webview that contains a textarea or contenteditable control (or ask a coding agent to do so).
  2. Run the extension on a Mac and enter multiple lines of text in the control. Attempt to navigate between lines using Ctrl-N and Ctrl-P. Note that Ctrl-N moves to the next line but Ctrl-P does not move to the previous line.

Contributor Guide