-
Notifications
You must be signed in to change notification settings - Fork 33.2k
Fix Alt+key copy shortcuts not working for HTML notebook outputs #251434
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
Co-authored-by: Yoyokrazy <12552271+Yoyokrazy@users.noreply.github.com>
Co-authored-by: Yoyokrazy <12552271+Yoyokrazy@users.noreply.github.com>
This is not an issue we can solve by listening for particular keystrokes. The user is allowed to set a completely arbitrary keystroke based upon their own needs, for example something like alt+w which is not a common or expected keystroke. It would appear that when the keystroke is used, the command is still triggered (the copy command), hoewver the holding of alt seems to be putting the HTML text into a technically unselected state (even though there is still a visual selection). Please try to address the root cause here. |
You're absolutely right. I've addressed the root cause by changing the approach entirely. Instead of trying to detect specific keystrokes, the fix now:
This approach preserves all keyboard shortcuts (including arbitrary user-configured ones) while still enabling drag-and-drop functionality when the user actually intends to drag content. Warning Firewall rules blocked me from connecting to one or more addressesI tried to connect to the following addresses, but was blocked by firewall rules:
If you need me to access, download, or install something from one of these locations, you can either:
|
Instead of blocking specific keystrokes, only enable drag when detecting actual drag intent (Alt+mousedown) and when there's no text selection. This preserves all keyboard shortcuts while maintaining drag functionality. Co-authored-by: Yoyokrazy <12552271+Yoyokrazy@users.noreply.github.com>
Users reported that keyboard shortcuts involving the Alt key (like Alt+C for copy) were not working for HTML notebook cell outputs, while they worked fine for plain text outputs and the standard Ctrl+C shortcut worked for all output types.
Root Cause
The issue was in the
OutputElement
class inwebviewPreloads.ts
. When implementing drag-and-drop functionality for notebook outputs, an Alt key handler was added that immediately setelement.draggable = true
whenever Alt was pressed:Making an element draggable can interfere with text selection and copy operations, preventing Alt-based keyboard shortcuts from working properly.
Solution
Modified the Alt keydown handler to check for common copy/paste/cut key combinations and skip making the element draggable in those cases:
What This Fixes
What Remains Working
This is a minimal, surgical fix that only affects the specific condition causing the problem while preserving all existing functionality.
Fixes #251433.
Warning
Firewall rules blocked me from connecting to one or more addresses
I tried to connect to the following addresses, but was blocked by firewall rules:
electronjs.org
node-gyp
(dns block)If you need me to access, download, or install something from one of these locations, you can either:
💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.