Ctrl-P text navigation shortcut does not work inside webview on macOS
#264,957 建立於 2025年9月3日
倉庫指標
- Star
- (74,848 star)
- PR 合併指標
- (平均合併 11小時 43分鐘) (30 天內合併 1,000 個 PR)
描述
- 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.