@@ -66,7 +66,8 @@ export class OutlinePane extends ViewPane {
66
66
67
67
private readonly _disposables = new DisposableStore ( ) ;
68
68
69
- private readonly _editorDisposables = new DisposableStore ( ) ;
69
+ private readonly _editorControlDisposables = new DisposableStore ( ) ;
70
+ private readonly _editorPaneDisposables = new DisposableStore ( ) ;
70
71
private readonly _outlineViewState = new OutlineViewState ( ) ;
71
72
72
73
private readonly _editorListener = new MutableDisposable ( ) ;
@@ -120,7 +121,8 @@ export class OutlinePane extends ViewPane {
120
121
121
122
override dispose ( ) : void {
122
123
this . _disposables . dispose ( ) ;
123
- this . _editorDisposables . dispose ( ) ;
124
+ this . _editorPaneDisposables . dispose ( ) ;
125
+ this . _editorControlDisposables . dispose ( ) ;
124
126
this . _editorListener . dispose ( ) ;
125
127
super . dispose ( ) ;
126
128
}
@@ -148,7 +150,8 @@ export class OutlinePane extends ViewPane {
148
150
if ( ! visible ) {
149
151
// stop everything when not visible
150
152
this . _editorListener . clear ( ) ;
151
- this . _editorDisposables . clear ( ) ;
153
+ this . _editorPaneDisposables . clear ( ) ;
154
+ this . _editorControlDisposables . clear ( ) ;
152
155
153
156
} else if ( ! this . _editorListener . value ) {
154
157
const event = Event . any ( this . _editorService . onDidActiveEditorChange , this . _outlineService . onDidChange ) ;
@@ -189,13 +192,26 @@ export class OutlinePane extends ViewPane {
189
192
return false ;
190
193
}
191
194
192
- private async _handleEditorChanged ( pane : IEditorPane | undefined ) : Promise < void > {
195
+ private _handleEditorChanged ( pane : IEditorPane | undefined ) : void {
196
+ this . _editorPaneDisposables . clear ( ) ;
197
+
198
+ if ( pane ) {
199
+ // react to control changes from within pane (https://github.com/microsoft/vscode/issues/134008)
200
+ this . _editorPaneDisposables . add ( pane . onDidChangeControl ( ( ) => {
201
+ this . _handleEditorControlChanged ( pane ) ;
202
+ } ) ) ;
203
+ }
204
+
205
+ this . _handleEditorControlChanged ( pane ) ;
206
+ }
207
+
208
+ private async _handleEditorControlChanged ( pane : IEditorPane | undefined ) : Promise < void > {
193
209
194
210
// persist state
195
211
const resource = EditorResourceAccessor . getOriginalUri ( pane ?. input ) ;
196
212
const didCapture = this . _captureViewState ( resource ) ;
197
213
198
- this . _editorDisposables . clear ( ) ;
214
+ this . _editorControlDisposables . clear ( ) ;
199
215
200
216
if ( ! pane || ! this . _outlineService . canCreateOutline ( pane ) || ! resource ) {
201
217
return this . _showMessage ( localize ( 'no-editor' , "The active editor cannot provide outline information." ) ) ;
@@ -211,7 +227,7 @@ export class OutlinePane extends ViewPane {
211
227
this . _progressBar . infinite ( ) . show ( 500 ) ;
212
228
213
229
const cts = new CancellationTokenSource ( ) ;
214
- this . _editorDisposables . add ( toDisposable ( ( ) => cts . dispose ( true ) ) ) ;
230
+ this . _editorControlDisposables . add ( toDisposable ( ( ) => cts . dispose ( true ) ) ) ;
215
231
216
232
const newOutline = await this . _outlineService . createOutline ( pane , OutlineTarget . OutlinePane , cts . token ) ;
217
233
loadingMessage ?. dispose ( ) ;
@@ -225,7 +241,7 @@ export class OutlinePane extends ViewPane {
225
241
return ;
226
242
}
227
243
228
- this . _editorDisposables . add ( newOutline ) ;
244
+ this . _editorControlDisposables . add ( newOutline ) ;
229
245
this . _progressBar . stop ( ) . hide ( ) ;
230
246
231
247
const sorter = new OutlineTreeSorter ( newOutline . config . comparator , this . _outlineViewState . sortBy ) ;
@@ -270,21 +286,21 @@ export class OutlinePane extends ViewPane {
270
286
}
271
287
} ;
272
288
updateTree ( ) ;
273
- this . _editorDisposables . add ( newOutline . onDidChange ( updateTree ) ) ;
289
+ this . _editorControlDisposables . add ( newOutline . onDidChange ( updateTree ) ) ;
274
290
275
291
// feature: apply panel background to tree
276
- this . _editorDisposables . add ( this . viewDescriptorService . onDidChangeLocation ( ( { views } ) => {
292
+ this . _editorControlDisposables . add ( this . viewDescriptorService . onDidChangeLocation ( ( { views } ) => {
277
293
if ( views . some ( v => v . id === this . id ) ) {
278
294
tree . updateOptions ( { overrideStyles : { listBackground : this . getBackgroundColor ( ) } } ) ;
279
295
}
280
296
} ) ) ;
281
297
282
298
// feature: filter on type - keep tree and menu in sync
283
- this . _editorDisposables . add ( tree . onDidUpdateOptions ( e => this . _outlineViewState . filterOnType = Boolean ( e . filterOnType ) ) ) ;
299
+ this . _editorControlDisposables . add ( tree . onDidUpdateOptions ( e => this . _outlineViewState . filterOnType = Boolean ( e . filterOnType ) ) ) ;
284
300
285
301
// feature: reveal outline selection in editor
286
302
// on change -> reveal/select defining range
287
- this . _editorDisposables . add ( tree . onDidOpen ( e => newOutline . reveal ( e . element , e . editorOptions , e . sideBySide ) ) ) ;
303
+ this . _editorControlDisposables . add ( tree . onDidOpen ( e => newOutline . reveal ( e . element , e . editorOptions , e . sideBySide ) ) ) ;
288
304
// feature: reveal editor selection in outline
289
305
const revealActiveElement = ( ) => {
290
306
if ( ! this . _outlineViewState . followCursor || ! newOutline . activeElement ) {
@@ -307,10 +323,10 @@ export class OutlinePane extends ViewPane {
307
323
}
308
324
} ;
309
325
revealActiveElement ( ) ;
310
- this . _editorDisposables . add ( newOutline . onDidChange ( revealActiveElement ) ) ;
326
+ this . _editorControlDisposables . add ( newOutline . onDidChange ( revealActiveElement ) ) ;
311
327
312
328
// feature: update view when user state changes
313
- this . _editorDisposables . add ( this . _outlineViewState . onDidChange ( ( e : { followCursor ?: boolean , sortBy ?: boolean , filterOnType ?: boolean } ) => {
329
+ this . _editorControlDisposables . add ( this . _outlineViewState . onDidChange ( ( e : { followCursor ?: boolean , sortBy ?: boolean , filterOnType ?: boolean } ) => {
314
330
this . _outlineViewState . persist ( this . _storageService ) ;
315
331
if ( e . filterOnType ) {
316
332
tree . updateOptions ( { filterOnType : this . _outlineViewState . filterOnType } ) ;
@@ -326,7 +342,7 @@ export class OutlinePane extends ViewPane {
326
342
327
343
// feature: expand all nodes when filtering (not when finding)
328
344
let viewState : IDataTreeViewState | undefined ;
329
- this . _editorDisposables . add ( tree . onDidChangeTypeFilterPattern ( pattern => {
345
+ this . _editorControlDisposables . add ( tree . onDidChangeTypeFilterPattern ( pattern => {
330
346
if ( ! tree . options . filterOnType ) {
331
347
return ;
332
348
}
@@ -342,7 +358,7 @@ export class OutlinePane extends ViewPane {
342
358
// last: set tree property
343
359
tree . layout ( this . _treeDimensions ?. height , this . _treeDimensions ?. width ) ;
344
360
this . _tree = tree ;
345
- this . _editorDisposables . add ( toDisposable ( ( ) => {
361
+ this . _editorControlDisposables . add ( toDisposable ( ( ) => {
346
362
tree . dispose ( ) ;
347
363
this . _tree = undefined ;
348
364
} ) ) ;
0 commit comments