Skip to content

Commit 8c85702

Browse files
authored
Explicitly clear web resources clipboard on copy (microsoft#185622)
Fixes microsoft#185466 Proper fix would be to use a future web clipboard API that lets you write any data types to the system clipboard
1 parent 7f8893b commit 8c85702

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

src/vs/editor/contrib/dropOrPasteInto/browser/copyPasteController.ts

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,18 @@ export class CopyPasteController extends Disposable implements IEditorContributi
114114
}
115115

116116
private handleCopy(e: ClipboardEvent) {
117-
if (!e.clipboardData || !this._editor.hasTextFocus() || !this.isPasteAsEnabled()) {
117+
if (!this._editor.hasTextFocus()) {
118+
return;
119+
}
120+
121+
if (platform.isWeb) {
122+
// Explicitly clear the web resources clipboard.
123+
// This is needed because on web, the browser clipboard is faked out using an in-memory store.
124+
// This means the resources clipboard is not properly updated when copying from the editor.
125+
this._clipboardService.writeResources([]);
126+
}
127+
128+
if (!e.clipboardData || !this.isPasteAsEnabled()) {
118129
return;
119130
}
120131

0 commit comments

Comments
 (0)