making sure the then on triggerPaste is not evaluated twice (#284961)
Some checks are pending
Monaco Editor checks / Monaco Editor checks (push) Waiting to run
Code OSS (node_modules) / Compile (push) Waiting to run
Code OSS (node_modules) / Linux (push) Waiting to run
Code OSS (node_modules) / macOS (push) Waiting to run
Code OSS (node_modules) / Windows (push) Waiting to run

making sure the then is not evaluated twice
This commit is contained in:
Aiday Marlen Kyzy 2025-12-24 17:56:26 +01:00 committed by GitHub
parent 2934fd48b2
commit 5d2a6f896d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 10 additions and 1 deletions

View File

@ -168,7 +168,8 @@ export const CopyOptions = {
};
export const PasteOptions = {
electronBugWorkaroundPasteEventHasFired: false
electronBugWorkaroundPasteEventHasFired: false,
electronBugWorkaroundPasteEventLock: false
};
interface InMemoryClipboardMetadata {

View File

@ -321,8 +321,16 @@ if (PasteAction) {
const triggerPaste = clipboardService.triggerPaste(getActiveWindow().vscodeWindowId);
if (triggerPaste) {
logService.trace('registerExecCommandImpl (triggerPaste defined)');
PasteOptions.electronBugWorkaroundPasteEventLock = false;
return triggerPaste.then(async () => {
if (PasteOptions.electronBugWorkaroundPasteEventHasFired === false) {
// Ensure this doesn't run twice, what appears to be happening is
// triggerPasteis called once but it's handler is called multiple times
// when it reproduces
if (PasteOptions.electronBugWorkaroundPasteEventLock === true) {
return;
}
PasteOptions.electronBugWorkaroundPasteEventLock = true;
return pasteWithNavigatorAPI(focusedEditor, clipboardService, logService);
}
logService.trace('registerExecCommandImpl (after triggerPaste)');