Skip to content

Conversation

@aiday-mar
Copy link
Contributor

No description provided.

Copilot AI review requested due to automatic review settings January 7, 2026 13:14
@aiday-mar aiday-mar self-assigned this Jan 7, 2026
Copy link
Contributor

Copilot AI left a 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 to NativeEditContext with 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);
Copy link

Copilot AI Jan 7, 2026

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.

Suggested change
const editContext = focusedEditor.getOption(EditorOption.editContext);
const editContext = focusedEditor.getOption(EditorOption.effectiveEditContext);

Copilot uses AI. Check for mistakes.
// 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 = '';
Copy link

Copilot AI Jan 7, 2026

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.

Suggested change
this._pasteTextArea.domNode.textContent = '';
this._pasteTextArea.domNode.value = '';

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants