mirror of
https://github.com/Microsoft/vscode
synced 2024-09-19 10:40:41 +00:00
perf - handle `workbench.contrib.textInputActionsProvider`
This commit is contained in:
parent
a3d4451154
commit
54488a73dd
|
@ -14,12 +14,13 @@ import { isNative } from 'vs/base/common/platform';
|
|||
import { IClipboardService } from 'vs/platform/clipboard/common/clipboardService';
|
||||
import { StandardMouseEvent } from 'vs/base/browser/mouseEvent';
|
||||
import { Event as BaseEvent } from 'vs/base/common/event';
|
||||
import { Lazy } from 'vs/base/common/lazy';
|
||||
|
||||
export class TextInputActionsProvider extends Disposable implements IWorkbenchContribution {
|
||||
|
||||
static readonly ID = 'workbench.contrib.textInputActionsProvider';
|
||||
|
||||
private textInputActions: IAction[] = [];
|
||||
private readonly textInputActions = new Lazy<IAction[]>(() => this.createActions());
|
||||
|
||||
constructor(
|
||||
@IWorkbenchLayoutService private readonly layoutService: IWorkbenchLayoutService,
|
||||
|
@ -28,13 +29,11 @@ export class TextInputActionsProvider extends Disposable implements IWorkbenchCo
|
|||
) {
|
||||
super();
|
||||
|
||||
this.createActions();
|
||||
|
||||
this.registerListeners();
|
||||
}
|
||||
|
||||
private createActions(): void {
|
||||
this.textInputActions.push(
|
||||
private createActions(): IAction[] {
|
||||
return [
|
||||
|
||||
// Undo/Redo
|
||||
new Action('undo', localize('undo', "Undo"), undefined, true, async () => getActiveDocument().execCommand('undo')),
|
||||
|
@ -72,7 +71,7 @@ export class TextInputActionsProvider extends Disposable implements IWorkbenchCo
|
|||
|
||||
// Select All
|
||||
new Action('editor.action.selectAll', localize('selectAll', "Select All"), undefined, true, async () => getActiveDocument().execCommand('selectAll'))
|
||||
);
|
||||
];
|
||||
}
|
||||
|
||||
private registerListeners(): void {
|
||||
|
@ -99,10 +98,14 @@ export class TextInputActionsProvider extends Disposable implements IWorkbenchCo
|
|||
|
||||
this.contextMenuService.showContextMenu({
|
||||
getAnchor: () => event,
|
||||
getActions: () => this.textInputActions,
|
||||
getActions: () => this.textInputActions.value,
|
||||
getActionsContext: () => target,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
registerWorkbenchContribution2(TextInputActionsProvider.ID, TextInputActionsProvider, WorkbenchContributionInstantiation.BlockRestore);
|
||||
registerWorkbenchContribution2(
|
||||
TextInputActionsProvider.ID,
|
||||
TextInputActionsProvider,
|
||||
WorkbenchContributionInstantiation.BlockRestore // Block to allow right-click into input fields before restore finished
|
||||
);
|
||||
|
|
Loading…
Reference in a new issue