Ctrl-P text navigation shortcut does not work inside webview on macOS
#264.957 aperta il 3 set 2025
Metriche repository
- Star
- (74.848 star)
- Metriche merge PR
- (Merge medio 11h 43m) (1000 PR mergiate in 30 g)
Descrizione
- 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:
- Create a simple VS Code extension with a webview that contains a textarea or contenteditable control (or ask a coding agent to do so).
- 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.