mirror of
https://github.com/microsoft/vscode.git
synced 2026-02-15 07:28:05 +00:00
making sure the then on triggerPaste is not evaluated twice (#284961)
making sure the then is not evaluated twice
This commit is contained in:
committed by
GitHub
parent
2934fd48b2
commit
5d2a6f896d
@@ -168,7 +168,8 @@ export const CopyOptions = {
|
||||
};
|
||||
|
||||
export const PasteOptions = {
|
||||
electronBugWorkaroundPasteEventHasFired: false
|
||||
electronBugWorkaroundPasteEventHasFired: false,
|
||||
electronBugWorkaroundPasteEventLock: false
|
||||
};
|
||||
|
||||
interface InMemoryClipboardMetadata {
|
||||
|
||||
@@ -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)');
|
||||
|
||||
Reference in New Issue
Block a user