-
Notifications
You must be signed in to change notification settings - Fork 37.3k
moving back to execCommand('paste') #286354
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR reverts the clipboard paste implementation to use the deprecated execCommand('paste') API instead of the modern triggerPaste clipboard service API. The change simplifies paste handling by removing complex workarounds for Electron paste event bugs and introduces a dedicated hidden textarea for paste operations in edit context scenarios.
Key changes:
- Simplified paste implementation to use
execCommand('paste')directly - Added
executePaste()method toNativeEditContextwith a dedicated paste textarea - Added
onPaste()screen reader support hooks across screen reader content implementations
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| src/vs/editor/contrib/clipboard/browser/clipboard.ts | Simplified paste implementation to use execCommand('paste'), removed triggerPaste workarounds and Electron bug handling code |
| src/vs/editor/browser/controller/editContext/native/nativeEditContext.ts | Added executePaste() method and dedicated _pasteTextArea for paste operations with edit context |
| src/vs/editor/browser/controller/editContext/native/screenReaderUtils.ts | Added onPaste() interface method for screen reader content |
| src/vs/editor/browser/controller/editContext/native/screenReaderSupport.ts | Added onPaste() method to delegate to screen reader content |
| src/vs/editor/browser/controller/editContext/native/screenReaderContentSimple.ts | Implemented onPaste() to ignore selection changes during paste |
| src/vs/editor/browser/controller/editContext/native/screenReaderContentRich.ts | Implemented onPaste() to ignore selection changes during paste |
| src/vs/editor/browser/controller/editContext/native/nativeEditContext.css | Added CSS styling for the new paste textarea |
| const editContextEnabled = focusedEditor.getOption(EditorOption.effectiveEditContext); | ||
| if (editContextEnabled) { | ||
| let result: boolean; | ||
| const editContext = focusedEditor.getOption(EditorOption.editContext); |
Copilot
AI
Jan 7, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should use EditorOption.effectiveEditContext instead of EditorOption.editContext. The effectiveEditContext is a computed option that checks both whether edit context is enabled in settings AND whether the environment actually supports it (via env.editContextSupported). Using just editContext could cause issues in environments where edit context is not supported. Other parts of this file (lines 253 and 287) correctly use effectiveEditContext.
| const editContext = focusedEditor.getOption(EditorOption.editContext); | |
| const editContext = focusedEditor.getOption(EditorOption.effectiveEditContext); |
| // we added a hidden text area that receives the paste execution | ||
| this._pasteTextArea.focus(); | ||
| const result = this._pasteTextArea.domNode.ownerDocument.execCommand('paste'); | ||
| this._pasteTextArea.domNode.textContent = ''; |
Copilot
AI
Jan 7, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For a textarea element, the .value property should be used instead of .textContent to clear its content. While both may work in some cases, .value is the correct DOM property for form input elements like textarea. This ensures proper clearing of the textarea's value and maintains consistency with standard DOM practices.
| this._pasteTextArea.domNode.textContent = ''; | |
| this._pasteTextArea.domNode.value = ''; |
No description provided.