Skip to content

Commit

Permalink
Add commands to hide the paste widget (#207379)
Browse files Browse the repository at this point in the history
  • Loading branch information
mjbvz authored Mar 12, 2024
1 parent 57f10c1 commit ba9f329
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand All @@ -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<IConfigurationRegistry>(ConfigurationExtensions.Configuration).registerConfiguration({
...editorConfigurationBaseNode,
Expand Down

0 comments on commit ba9f329

Please sign in to comment.