Skip to content

Commit

Permalink
Explicitly clear web resources clipboard on copy (#185622)
Browse files Browse the repository at this point in the history
Fixes #185466

Proper fix would be to use a future web clipboard API that lets you write any data types to the system clipboard
  • Loading branch information
mjbvz authored Jun 20, 2023
1 parent 7f8893b commit 8c85702
Showing 1 changed file with 12 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,18 @@ export class CopyPasteController extends Disposable implements IEditorContributi
}

private handleCopy(e: ClipboardEvent) {
if (!e.clipboardData || !this._editor.hasTextFocus() || !this.isPasteAsEnabled()) {
if (!this._editor.hasTextFocus()) {
return;
}

if (platform.isWeb) {
// Explicitly clear the web resources clipboard.
// This is needed because on web, the browser clipboard is faked out using an in-memory store.
// This means the resources clipboard is not properly updated when copying from the editor.
this._clipboardService.writeResources([]);
}

if (!e.clipboardData || !this.isPasteAsEnabled()) {
return;
}

Expand Down

0 comments on commit 8c85702

Please sign in to comment.