5
5
6
6
import { IKeyboardEvent } from 'vs/base/browser/keyboardEvent' ;
7
7
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' ;
9
9
import { URI } from 'vs/base/common/uri' ;
10
10
import { IEditorConstructionOptions } from 'vs/editor/browser/config/editorConfiguration' ;
11
11
import { EditorExtensionsRegistry } from 'vs/editor/browser/editorExtensions' ;
@@ -92,10 +92,15 @@ class AccessibleView extends Disposable {
92
92
}
93
93
94
94
show ( provider : IAccessibleContentProvider ) : void {
95
+ let view : IDisposable | undefined ;
95
96
const delegate : IContextViewDelegate = {
96
97
getAnchor : ( ) => this . _editorContainer ,
97
98
render : ( container ) => {
98
- return this . _render ( provider , container ) ;
99
+ view = this . _render ( provider , container ) ;
100
+ return view ;
101
+ } ,
102
+ onHide : ( ) => {
103
+ view ?. dispose ( ) ;
99
104
}
100
105
} ;
101
106
this . _contextViewService . showContextView ( delegate ) ;
@@ -121,28 +126,34 @@ class AccessibleView extends Disposable {
121
126
model . setLanguage ( provider . options . language ) ;
122
127
}
123
128
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 ( ) ) ) ;
142
129
this . _editorWidget . updateOptions ( { ariaLabel : provider . options . ariaLabel } ) ;
143
130
this . _editorWidget . focus ( ) ;
144
131
} ) ;
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 ( ) ; } ) ;
146
157
}
147
158
148
159
private _layout ( ) : void {
0 commit comments