diff --git a/src/vs/editor/contrib/dropOrPasteInto/browser/copyPasteContribution.ts b/src/vs/editor/contrib/dropOrPasteInto/browser/copyPasteContribution.ts index c291012f89fd0..b3f5defb48f12 100644 --- a/src/vs/editor/contrib/dropOrPasteInto/browser/copyPasteContribution.ts +++ b/src/vs/editor/contrib/dropOrPasteInto/browser/copyPasteContribution.ts @@ -16,7 +16,6 @@ import * as nls from 'vs/nls'; import { KeybindingWeight } from 'vs/platform/keybinding/common/keybindingsRegistry'; registerEditorContribution(CopyPasteController.ID, CopyPasteController, EditorContributionInstantiation.Eager); // eager because it listens to events on the container dom node of the editor - registerEditorFeature(DefaultPasteProvidersFeature); registerEditorCommand(new class extends EditorCommand { @@ -31,11 +30,27 @@ registerEditorCommand(new class extends EditorCommand { }); } - public override runEditorCommand(_accessor: ServicesAccessor | null, editor: ICodeEditor, _args: any) { + public override runEditorCommand(_accessor: ServicesAccessor | null, editor: ICodeEditor) { return CopyPasteController.get(editor)?.changePasteType(); } }); +registerEditorCommand(new class extends EditorCommand { + constructor() { + super({ + id: 'editor.hidePasteWidget', + precondition: pasteWidgetVisibleCtx, + kbOpts: { + weight: KeybindingWeight.EditorContrib, + primary: KeyCode.Escape, + } + }); + } + + public override runEditorCommand(_accessor: ServicesAccessor | null, editor: ICodeEditor) { + CopyPasteController.get(editor)?.clearWidgets(); + } +}); registerEditorAction(class PasteAsAction extends EditorAction { diff --git a/src/vs/editor/contrib/dropOrPasteInto/browser/dropIntoEditorContribution.ts b/src/vs/editor/contrib/dropOrPasteInto/browser/dropIntoEditorContribution.ts index 4817431d18934..52dc73b8ce23a 100644 --- a/src/vs/editor/contrib/dropOrPasteInto/browser/dropIntoEditorContribution.ts +++ b/src/vs/editor/contrib/dropOrPasteInto/browser/dropIntoEditorContribution.ts @@ -16,6 +16,7 @@ import { Registry } from 'vs/platform/registry/common/platform'; import { DropIntoEditorController, changeDropTypeCommandId, defaultProviderConfig, dropWidgetVisibleCtx } from './dropIntoEditorController'; registerEditorContribution(DropIntoEditorController.ID, DropIntoEditorController, EditorContributionInstantiation.BeforeFirstInteraction); +registerEditorFeature(DefaultDropProvidersFeature); registerEditorCommand(new class extends EditorCommand { constructor() { @@ -34,7 +35,22 @@ registerEditorCommand(new class extends EditorCommand { } }); -registerEditorFeature(DefaultDropProvidersFeature); +registerEditorCommand(new class extends EditorCommand { + constructor() { + super({ + id: 'editor.hideDropWidget', + precondition: dropWidgetVisibleCtx, + kbOpts: { + weight: KeybindingWeight.EditorContrib, + primary: KeyCode.Escape, + } + }); + } + + public override runEditorCommand(_accessor: ServicesAccessor | null, editor: ICodeEditor, _args: any) { + DropIntoEditorController.get(editor)?.clearWidgets(); + } +}); Registry.as(ConfigurationExtensions.Configuration).registerConfiguration({ ...editorConfigurationBaseNode,