Skip to content

WORKAROUND - paste fix - using readText from navigator API when triggerPaste fails#283571

Merged
aiday-mar merged 8 commits intomainfrom
endless-orca
Dec 15, 2025
Merged

WORKAROUND - paste fix - using readText from navigator API when triggerPaste fails#283571
aiday-mar merged 8 commits intomainfrom
endless-orca

Conversation

@aiday-mar
Copy link
Contributor

using readText from navigator API when triggerPaste fails
counterpart to copy issue

Copilot AI review requested due to automatic review settings December 15, 2025 11:59
@aiday-mar aiday-mar self-assigned this Dec 15, 2025
@aiday-mar aiday-mar marked this pull request as draft December 15, 2025 11:59
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 implements a fallback mechanism for paste operations when triggerPaste fails, mirroring the existing workaround for copy operations. The change refactors paste handling logic across multiple editor contexts and introduces a flag-based detection system to determine when the clipboard paste event doesn't fire properly.

Key Changes

  • Adds pasteWithNavigatorAPI function as a fallback when triggerPaste doesn't fire paste events
  • Refactors common paste data processing logic into reusable utility functions (computePasteData and getPasteDataFromMetadata)
  • Introduces PasteOptions.electronBugWorkaroundPasteEventHasFired flag to detect when paste events fail to fire

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
src/vs/editor/contrib/clipboard/browser/clipboard.ts Adds pasteWithNavigatorAPI fallback function and integrates it into paste command handling with workaround flag check
src/vs/editor/browser/controller/editContext/clipboardUtils.ts Introduces IPasteData interface, computePasteData, getPasteDataFromMetadata utility functions, and PasteOptions flag
src/vs/editor/browser/controller/editContext/textArea/textAreaEditContextInput.ts Refactors paste event handling to use new utility functions and moves IPasteData interface to clipboardUtils
src/vs/editor/browser/controller/editContext/textArea/textAreaEditContext.ts Simplifies paste event handler by using pre-computed IPasteData fields and removes duplicate _emptySelectionClipboard field
src/vs/editor/browser/controller/editContext/native/nativeEditContext.ts Refactors paste event handling to use computePasteData utility function

Comment on lines 330 to 332
if (!PasteOptions.electronBugWorkaroundPasteEventHasFired) {
return pasteWithNavigatorAPI(focusedEditor, clipboardService, logService);
}
Copy link

Copilot AI Dec 15, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The PasteOptions.electronBugWorkaroundPasteEventHasFired flag is never reset to false before checking it. Unlike the copy workaround pattern (see line 203 where CopyOptions.electronBugWorkaroundCopyEventHasFired is reset before execCommand('copy')), this flag remains true after the first paste event, causing all subsequent paste operations via triggerPaste to incorrectly fall back to the Navigator API even when the paste event fires successfully. The flag should be reset to false before calling clipboardService.triggerPaste() at line 326.

Copilot uses AI. Check for mistakes.
}
}

async function pasteWithNavigatorAPI(editor: IActiveCodeEditor, clipboardService: IClipboardService, logService: ILogService): Promise<void> {
Copy link

Copilot AI Dec 15, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The function name pasteWithNavigatorAPI is inconsistent with the actual implementation. The function uses clipboardService.readText() which is an abstraction that may or may not use the Navigator API depending on the platform. A more accurate name would be pasteFromClipboardService or pasteWithFallback to reflect that it's using the clipboard service abstraction rather than directly calling the Navigator API.

Suggested change
async function pasteWithNavigatorAPI(editor: IActiveCodeEditor, clipboardService: IClipboardService, logService: ILogService): Promise<void> {
async function pasteFromClipboardService(editor: IActiveCodeEditor, clipboardService: IClipboardService, logService: ILogService): Promise<void> {

Copilot uses AI. Check for mistakes.
@aiday-mar aiday-mar changed the title paste fix - using readText from navigator API when triggerPaste fails WORKAROUND - paste fix - using readText from navigator API when triggerPaste fails Dec 15, 2025
@aiday-mar aiday-mar marked this pull request as ready for review December 15, 2025 12:36
@vs-code-engineering vs-code-engineering bot added this to the December / January 2026 milestone Dec 15, 2025
@aiday-mar aiday-mar enabled auto-merge (squash) December 15, 2025 15:32
@aiday-mar aiday-mar merged commit fd7fb44 into main Dec 15, 2025
28 checks passed
@aiday-mar aiday-mar deleted the endless-orca branch December 15, 2025 16:25
alexdima added a commit that referenced this pull request Jan 8, 2026
alexdima added a commit that referenced this pull request Jan 8, 2026
@vs-code-engineering vs-code-engineering bot locked and limited conversation to collaborators Jan 29, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants