Disable copy/paste actions if editor is not focused (#152125)

This fixes copy/paste triggering when you copy/paste in the rename widget for example
This commit is contained in:
Matt Bierner
2022-06-14 15:37:47 -07:00
committed by GitHub
parent 00273730e8
commit 7d729bbcc8

View File

@@ -34,9 +34,7 @@ const defaultPasteEditProvider = new class implements DocumentPasteEditProvider
const textDataTransfer = dataTransfer.get(Mimes.text) ?? dataTransfer.get('text');
if (textDataTransfer) {
const text = await textDataTransfer.asString();
return {
insertText: text
};
return { insertText: text };
}
return undefined;
@@ -82,7 +80,7 @@ export class CopyPasteController extends Disposable implements IEditorContributi
}
private handleCopy(e: ClipboardEvent) {
if (!e.clipboardData) {
if (!e.clipboardData || !this._editor.hasTextFocus()) {
return;
}
@@ -126,8 +124,12 @@ export class CopyPasteController extends Disposable implements IEditorContributi
}
private async handlePaste(e: ClipboardEvent) {
if (!e.clipboardData || !this._editor.hasTextFocus()) {
return;
}
const selections = this._editor.getSelections();
if (!e.clipboardData || !selections?.length || !this._editor.hasModel()) {
if (!selections?.length || !this._editor.hasModel()) {
return;
}