Skip to content

Commit 2aa71dc

Browse files
committed
1 parent ed9fc30 commit 2aa71dc

File tree

1 file changed

+32
-21
lines changed

1 file changed

+32
-21
lines changed

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

Lines changed: 32 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
import { IKeyboardEvent } from 'vs/base/browser/keyboardEvent';
77
import { KeyCode } from 'vs/base/common/keyCodes';
8-
import { Disposable, toDisposable } from 'vs/base/common/lifecycle';
8+
import { Disposable, DisposableStore, toDisposable } from 'vs/base/common/lifecycle';
99
import { URI } from 'vs/base/common/uri';
1010
import { IEditorConstructionOptions } from 'vs/editor/browser/config/editorConfiguration';
1111
import { EditorExtensionsRegistry } from 'vs/editor/browser/editorExtensions';
@@ -92,10 +92,15 @@ class AccessibleView extends Disposable {
9292
}
9393

9494
show(provider: IAccessibleContentProvider): void {
95+
let view: IDisposable | undefined;
9596
const delegate: IContextViewDelegate = {
9697
getAnchor: () => this._editorContainer,
9798
render: (container) => {
98-
return this._render(provider, container);
99+
view = this._render(provider, container);
100+
return view;
101+
},
102+
onHide: () => {
103+
view?.dispose();
99104
}
100105
};
101106
this._contextViewService.showContextView(delegate);
@@ -121,28 +126,34 @@ class AccessibleView extends Disposable {
121126
model.setLanguage(provider.options.language);
122127
}
123128
container.appendChild(this._editorContainer);
124-
this._keyListener = this._register(this._editorWidget.onKeyUp((e) => {
125-
if (e.keyCode === KeyCode.Escape) {
126-
this._contextViewService.hideContextView();
127-
// Delay to allow the context view to hide #186514
128-
setTimeout(() => provider.onClose(), 100);
129-
this._keyListener?.dispose();
130-
} else if (e.keyCode === KeyCode.KeyD && this._configurationService.getValue(settingKey)) {
131-
this._configurationService.updateValue(settingKey, false);
132-
} else if (e.keyCode === KeyCode.KeyH && provider.options.readMoreUrl) {
133-
const url: string = provider.options.readMoreUrl!;
134-
alert(AccessibilityHelpNLS.openingDocs);
135-
this._openerService.open(URI.parse(url));
136-
}
137-
e.stopPropagation();
138-
provider.onKeyDown?.(e);
139-
}));
140-
this._register(this._editorWidget.onDidBlurEditorText(() => this._contextViewService.hideContextView()));
141-
this._register(this._editorWidget.onDidContentSizeChange(() => this._layout()));
142129
this._editorWidget.updateOptions({ ariaLabel: provider.options.ariaLabel });
143130
this._editorWidget.focus();
144131
});
145-
return toDisposable(() => { });
132+
const disposableStore = new DisposableStore();
133+
disposableStore.add(this._editorWidget.onKeyUp((e) => {
134+
if (e.keyCode === KeyCode.Escape) {
135+
this._contextViewService.hideContextView();
136+
// Delay to allow the context view to hide #186514
137+
setTimeout(() => provider.onClose(), 100);
138+
this._keyListener?.dispose();
139+
} else if (e.keyCode === KeyCode.KeyD && this._configurationService.getValue(settingKey)) {
140+
this._configurationService.updateValue(settingKey, false);
141+
}
142+
e.stopPropagation();
143+
provider.onKeyDown?.(e);
144+
}));
145+
disposableStore.add(this._editorWidget.onKeyDown((e) => {
146+
if (e.keyCode === KeyCode.KeyH && provider.options.readMoreUrl) {
147+
const url: string = provider.options.readMoreUrl!;
148+
alert(AccessibilityHelpNLS.openingDocs);
149+
this._openerService.open(URI.parse(url));
150+
e.preventDefault();
151+
e.stopPropagation();
152+
}
153+
}));
154+
disposableStore.add(this._editorWidget.onDidBlurEditorText(() => this._contextViewService.hideContextView()));
155+
disposableStore.add(this._editorWidget.onDidContentSizeChange(() => this._layout()));
156+
return toDisposable(() => { disposableStore.dispose(); });
146157
}
147158

148159
private _layout(): void {

0 commit comments

Comments
 (0)