Skip to content

Commit 54488a7

Browse files
authored
perf - handle workbench.contrib.textInputActionsProvider (microsoft#203947) (microsoft#203958)
perf - handle `workbench.contrib.textInputActionsProvider`
1 parent a3d4451 commit 54488a7

File tree

1 file changed

+11
-8
lines changed

1 file changed

+11
-8
lines changed

src/vs/workbench/browser/actions/textInputActions.ts

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,13 @@ import { isNative } from 'vs/base/common/platform';
1414
import { IClipboardService } from 'vs/platform/clipboard/common/clipboardService';
1515
import { StandardMouseEvent } from 'vs/base/browser/mouseEvent';
1616
import { Event as BaseEvent } from 'vs/base/common/event';
17+
import { Lazy } from 'vs/base/common/lazy';
1718

1819
export class TextInputActionsProvider extends Disposable implements IWorkbenchContribution {
1920

2021
static readonly ID = 'workbench.contrib.textInputActionsProvider';
2122

22-
private textInputActions: IAction[] = [];
23+
private readonly textInputActions = new Lazy<IAction[]>(() => this.createActions());
2324

2425
constructor(
2526
@IWorkbenchLayoutService private readonly layoutService: IWorkbenchLayoutService,
@@ -28,13 +29,11 @@ export class TextInputActionsProvider extends Disposable implements IWorkbenchCo
2829
) {
2930
super();
3031

31-
this.createActions();
32-
3332
this.registerListeners();
3433
}
3534

36-
private createActions(): void {
37-
this.textInputActions.push(
35+
private createActions(): IAction[] {
36+
return [
3837

3938
// Undo/Redo
4039
new Action('undo', localize('undo', "Undo"), undefined, true, async () => getActiveDocument().execCommand('undo')),
@@ -72,7 +71,7 @@ export class TextInputActionsProvider extends Disposable implements IWorkbenchCo
7271

7372
// Select All
7473
new Action('editor.action.selectAll', localize('selectAll', "Select All"), undefined, true, async () => getActiveDocument().execCommand('selectAll'))
75-
);
74+
];
7675
}
7776

7877
private registerListeners(): void {
@@ -99,10 +98,14 @@ export class TextInputActionsProvider extends Disposable implements IWorkbenchCo
9998

10099
this.contextMenuService.showContextMenu({
101100
getAnchor: () => event,
102-
getActions: () => this.textInputActions,
101+
getActions: () => this.textInputActions.value,
103102
getActionsContext: () => target,
104103
});
105104
}
106105
}
107106

108-
registerWorkbenchContribution2(TextInputActionsProvider.ID, TextInputActionsProvider, WorkbenchContributionInstantiation.BlockRestore);
107+
registerWorkbenchContribution2(
108+
TextInputActionsProvider.ID,
109+
TextInputActionsProvider,
110+
WorkbenchContributionInstantiation.BlockRestore // Block to allow right-click into input fields before restore finished
111+
);

0 commit comments

Comments
 (0)