@@ -47,6 +47,7 @@ export class ViewDescriptorService extends Disposable implements IViewDescriptor
47
47
48
48
private readonly viewContainerModels = this . _register ( new DisposableMap < ViewContainer , { viewContainerModel : ViewContainerModel ; disposables : DisposableStore } & IDisposable > ( ) ) ;
49
49
private readonly viewsVisibilityActionDisposables = this . _register ( new DisposableMap < ViewContainer , IDisposable > ( ) ) ;
50
+ private canRegisterViewsVisibilityActions : boolean = false ;
50
51
private readonly activeViewContextKeys : Map < string , IContextKey < boolean > > ;
51
52
private readonly movableViewContextKeys : Map < string , IContextKey < boolean > > ;
52
53
private readonly defaultViewLocationContextKeys : Map < string , IContextKey < boolean > > ;
@@ -202,7 +203,10 @@ export class ViewDescriptorService extends Disposable implements IViewDescriptor
202
203
this . saveViewCustomizations ( ) ;
203
204
204
205
// Register visibility actions for all views
205
- this . registerViewsVisibilityActions ( ) ;
206
+ for ( const [ key , value ] of this . viewContainerModels ) {
207
+ this . registerViewsVisibilityActions ( key , value ) ;
208
+ }
209
+ this . canRegisterViewsVisibilityActions = true ;
206
210
}
207
211
208
212
private onDidRegisterViews ( views : { views : IViewDescriptor [ ] ; viewContainer : ViewContainer } [ ] ) : void {
@@ -697,7 +701,8 @@ export class ViewDescriptorService extends Disposable implements IViewDescriptor
697
701
698
702
disposables . add ( this . registerResetViewContainerAction ( viewContainer ) ) ;
699
703
700
- this . viewContainerModels . set ( viewContainer , { viewContainerModel : viewContainerModel , disposables, dispose : ( ) => disposables . dispose ( ) } ) ;
704
+ const value = { viewContainerModel : viewContainerModel , disposables, dispose : ( ) => disposables . dispose ( ) } ;
705
+ this . viewContainerModels . set ( viewContainer , value ) ;
701
706
702
707
// Register all views that were statically registered to this container
703
708
// Potentially, this is registering something that was handled by another container
@@ -712,13 +717,18 @@ export class ViewDescriptorService extends Disposable implements IViewDescriptor
712
717
viewsToRegister . forEach ( viewDescriptor => this . getOrCreateMovableViewContextKey ( viewDescriptor ) . set ( ! ! viewDescriptor . canMoveView ) ) ;
713
718
} ) ;
714
719
}
720
+
721
+ if ( this . canRegisterViewsVisibilityActions ) {
722
+ this . registerViewsVisibilityActions ( viewContainer , value ) ;
723
+ }
715
724
}
716
725
717
726
return viewContainerModel ;
718
727
}
719
728
720
729
private onDidDeregisterViewContainer ( viewContainer : ViewContainer ) : void {
721
730
this . viewContainerModels . deleteAndDispose ( viewContainer ) ;
731
+ this . viewsVisibilityActionDisposables . deleteAndDispose ( viewContainer ) ;
722
732
}
723
733
724
734
private onDidChangeActiveViews ( { added, removed } : { added : ReadonlyArray < IViewDescriptor > ; removed : ReadonlyArray < IViewDescriptor > } ) : void {
@@ -735,16 +745,14 @@ export class ViewDescriptorService extends Disposable implements IViewDescriptor
735
745
} ) ;
736
746
}
737
747
738
- private registerViewsVisibilityActions ( ) : void {
739
- for ( const [ viewContainer , { viewContainerModel, disposables } ] of this . viewContainerModels ) {
740
- this . viewsVisibilityActionDisposables . set ( viewContainer , this . registerViewsVisibilityActionsForContainer ( viewContainerModel ) ) ;
741
- disposables . add ( Event . any (
742
- viewContainerModel . onDidChangeActiveViewDescriptors ,
743
- viewContainerModel . onDidAddVisibleViewDescriptors ,
744
- viewContainerModel . onDidRemoveVisibleViewDescriptors ,
745
- viewContainerModel . onDidMoveVisibleViewDescriptors
746
- ) ( e => this . viewsVisibilityActionDisposables . set ( viewContainer , this . registerViewsVisibilityActionsForContainer ( viewContainerModel ) ) ) ) ;
747
- }
748
+ private registerViewsVisibilityActions ( viewContainer : ViewContainer , { viewContainerModel, disposables } : { viewContainerModel : ViewContainerModel ; disposables : DisposableStore } ) : void {
749
+ this . viewsVisibilityActionDisposables . set ( viewContainer , this . registerViewsVisibilityActionsForContainer ( viewContainerModel ) ) ;
750
+ disposables . add ( Event . any (
751
+ viewContainerModel . onDidChangeActiveViewDescriptors ,
752
+ viewContainerModel . onDidAddVisibleViewDescriptors ,
753
+ viewContainerModel . onDidRemoveVisibleViewDescriptors ,
754
+ viewContainerModel . onDidMoveVisibleViewDescriptors
755
+ ) ( e => this . viewsVisibilityActionDisposables . set ( viewContainer , this . registerViewsVisibilityActionsForContainer ( viewContainerModel ) ) ) ) ;
748
756
}
749
757
750
758
private registerViewsVisibilityActionsForContainer ( viewContainerModel : ViewContainerModel ) : IDisposable {
0 commit comments