Skip to content

Commit 67de6de

Browse files
authored
Lazily create the accessibility help widget (microsoft#164166)
In most instances this widget is never used, so we should avoid creating it eagerly
1 parent da14061 commit 67de6de

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

src/vs/workbench/contrib/codeEditor/browser/accessibility/accessibility.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,24 +46,26 @@ export class AccessibilityHelpController extends Disposable implements IEditorCo
4646
}
4747

4848
private _editor: ICodeEditor;
49-
private _widget: AccessibilityHelpWidget;
49+
private _widget?: AccessibilityHelpWidget;
5050

5151
constructor(
5252
editor: ICodeEditor,
53-
@IInstantiationService instantiationService: IInstantiationService
53+
@IInstantiationService private readonly instantiationService: IInstantiationService
5454
) {
5555
super();
5656

5757
this._editor = editor;
58-
this._widget = this._register(instantiationService.createInstance(AccessibilityHelpWidget, this._editor));
5958
}
6059

6160
public show(): void {
61+
if (!this._widget) {
62+
this._widget = this._register(this.instantiationService.createInstance(AccessibilityHelpWidget, this._editor));
63+
}
6264
this._widget.show();
6365
}
6466

6567
public hide(): void {
66-
this._widget.hide();
68+
this._widget?.hide();
6769
}
6870
}
6971

0 commit comments

Comments
 (0)