From a5eb0120c180dd75e770db186397bad33364c6cf Mon Sep 17 00:00:00 2001 From: SvDp Date: Thu, 25 Dec 2025 12:58:44 +0530 Subject: [PATCH] Fix Ctrl+P text navigation in webview on macOS On macOS, Ctrl+P is a standard emacs-style shortcut for moving to the previous line in text input controls. The current implementation incorrectly suppresses this shortcut by treating it as the Print command, which is Windows-specific behavior. This change adds macOS platform detection and modifies the isPrint() function to only suppress Ctrl+P on non-macOS platforms. On macOS, Cmd+P continues to correctly trigger the print behavior. Fixes #264957 --- src/vs/workbench/contrib/webview/browser/pre/index.html | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/vs/workbench/contrib/webview/browser/pre/index.html b/src/vs/workbench/contrib/webview/browser/pre/index.html index 9bd67086fd042..82ccc8992593c 100644 --- a/src/vs/workbench/contrib/webview/browser/pre/index.html +++ b/src/vs/workbench/contrib/webview/browser/pre/index.html @@ -29,6 +29,9 @@ navigator.userAgent.indexOf('Firefox') >= 0 ); + const isMacOS = navigator.platform?.toUpperCase().includes('MAC') || + navigator.userAgent?.toUpperCase().includes('MAC'); + const searchParams = new URL(location.toString()).searchParams; const ID = searchParams.get('id'); const webviewOrigin = searchParams.get('origin'); @@ -688,6 +691,9 @@ * @return {boolean} */ function isPrint(e) { + if (isMacOS && e.ctrlKey && !e.metaKey) { + return false; + } const hasMeta = e.ctrlKey || e.metaKey; // 80: keyCode of "P" return hasMeta && e.keyCode === 80;