@@ -33,12 +33,13 @@ import { IContextKey, IContextKeyService, ContextKeyExpr } from 'vs/platform/con
3333import { isUndefinedOrNull , assertIsDefined } from 'vs/base/common/types' ;
3434import { registerSingleton } from 'vs/platform/instantiation/common/extensions' ;
3535import { IExtensionService } from 'vs/workbench/services/extensions/common/extensions' ;
36- import { ViewContainer , IViewContainersRegistry , Extensions as ViewContainerExtensions , IViewDescriptorService , IViewDescriptorCollection , ViewContainerLocation } from 'vs/workbench/common/views' ;
36+ import { ViewContainer , IViewContainersRegistry , Extensions as ViewContainerExtensions , IViewDescriptorService , IViewContainerModel , ViewContainerLocation } from 'vs/workbench/common/views' ;
3737import { MenuId } from 'vs/platform/actions/common/actions' ;
3838import { ViewMenuActions } from 'vs/workbench/browser/parts/views/viewMenuActions' ;
3939import { IPaneComposite } from 'vs/workbench/common/panecomposite' ;
4040import { IStorageKeysSyncRegistryService } from 'vs/platform/userDataSync/common/storageKeys' ;
4141import { Before2D } from 'vs/workbench/browser/dnd' ;
42+ import { IActivity } from 'vs/workbench/common/activity' ;
4243
4344interface ICachedPanel {
4445 id : string ;
@@ -177,9 +178,9 @@ export class PanelPart extends CompositePart<Panel> implements IPanelService {
177178 const result : IAction [ ] = [ ] ;
178179 const container = this . getViewContainer ( compositeId ) ;
179180 if ( container ) {
180- const viewDescriptors = this . viewDescriptorService . getViewDescriptors ( container ) ;
181- if ( viewDescriptors . allViewDescriptors . length === 1 ) {
182- const viewMenuActions = this . instantiationService . createInstance ( ViewMenuActions , viewDescriptors . allViewDescriptors [ 0 ] . id , MenuId . ViewTitle , MenuId . ViewTitleContext ) ;
181+ const viewContainerModel = this . viewDescriptorService . getViewContainerModel ( container ) ;
182+ if ( viewContainerModel . allViewDescriptors . length === 1 ) {
183+ const viewMenuActions = this . instantiationService . createInstance ( ViewMenuActions , viewContainerModel . allViewDescriptors [ 0 ] . id , MenuId . ViewTitle , MenuId . ViewTitleContext ) ;
183184 result . push ( ...viewMenuActions . getContextMenuActions ( ) ) ;
184185 viewMenuActions . dispose ( ) ;
185186 }
@@ -209,12 +210,16 @@ export class PanelPart extends CompositePart<Panel> implements IPanelService {
209210
210211 for ( const panel of panels ) {
211212 this . enableCompositeActions ( panel ) ;
212- const viewContainer = this . getViewContainer ( panel . id ) ;
213- if ( viewContainer ?. hideIfEmpty ) {
214- const viewDescriptors = this . viewDescriptorService . getViewDescriptors ( viewContainer ) ;
215- this . onDidChangeActiveViews ( panel , viewDescriptors ) ;
216- this . panelDisposables . set ( panel . id , viewDescriptors . onDidChangeActiveViews ( ( ) => this . onDidChangeActiveViews ( panel , viewDescriptors ) ) ) ;
217- }
213+ const viewContainer = this . getViewContainer ( panel . id ) ! ;
214+ const viewContainerModel = this . viewDescriptorService . getViewContainerModel ( viewContainer ) ;
215+ this . onDidChangeActiveViews ( panel , viewContainerModel , viewContainer . hideIfEmpty ) ;
216+
217+ const disposables = new DisposableStore ( ) ;
218+ disposables . add ( viewContainerModel . onDidChangeActiveViewDescriptors ( ( ) => this . onDidChangeActiveViews ( panel , viewContainerModel , viewContainer . hideIfEmpty ) ) ) ;
219+ disposables . add ( viewContainerModel . onDidChangeAllViewDescriptors ( ( ) => this . onDidUpdateViews ( panel , viewContainerModel ) ) ) ;
220+ disposables . add ( viewContainerModel . onDidMoveVisibleViewDescriptors ( ( ) => this . onDidUpdateViews ( panel , viewContainerModel ) ) ) ;
221+
222+ this . panelDisposables . set ( panel . id , disposables ) ;
218223 }
219224 }
220225
@@ -230,19 +235,37 @@ export class PanelPart extends CompositePart<Panel> implements IPanelService {
230235
231236 private enableCompositeActions ( panel : PanelDescriptor ) : void {
232237 const { activityAction, pinnedAction } = this . getCompositeActions ( panel . id ) ;
233- if ( activityAction instanceof PlaceHolderPanelActivityAction ) {
234- activityAction . setActivity ( panel ) ;
235- }
238+ activityAction . setActivity ( panel ) ;
236239
237240 if ( pinnedAction instanceof PlaceHolderToggleCompositePinnedAction ) {
238241 pinnedAction . setActivity ( panel ) ;
239242 }
240243 }
241244
242- private onDidChangeActiveViews ( panel : PanelDescriptor , viewDescriptors : IViewDescriptorCollection ) : void {
245+ private updateActivity ( panel : PanelDescriptor , viewContainerModel : IViewContainerModel ) : void {
246+ const activity : IActivity = {
247+ id : panel . id ,
248+ name : viewContainerModel . title ,
249+ keybindingId : panel . keybindingId
250+ } ;
251+
252+ const { activityAction, pinnedAction } = this . getCompositeActions ( panel . id ) ;
253+ activityAction . setActivity ( activity ) ;
254+
255+ if ( pinnedAction instanceof PlaceHolderToggleCompositePinnedAction ) {
256+ pinnedAction . setActivity ( activity ) ;
257+ }
258+ }
259+
260+ private onDidUpdateViews ( panel : PanelDescriptor , viewDescriptors : IViewContainerModel ) : void {
261+ this . updateActivity ( panel , viewDescriptors ) ;
262+ }
263+
264+ private onDidChangeActiveViews ( panel : PanelDescriptor , viewDescriptors : IViewContainerModel , hideIfEmpty ?: boolean ) : void {
243265 if ( viewDescriptors . activeViewDescriptors . length ) {
266+ this . updateActivity ( panel , viewDescriptors ) ;
244267 this . compositeBar . addComposite ( panel ) ;
245- } else {
268+ } else if ( hideIfEmpty ) {
246269 this . hideComposite ( panel . id ) ;
247270 }
248271 }
@@ -320,8 +343,8 @@ export class PanelPart extends CompositePart<Panel> implements IPanelService {
320343 if ( panelDescriptor ) {
321344 const viewContainer = this . getViewContainer ( panelDescriptor . id ) ;
322345 if ( viewContainer ?. hideIfEmpty ) {
323- const viewDescriptors = this . viewDescriptorService . getViewDescriptors ( viewContainer ) ;
324- if ( viewDescriptors . activeViewDescriptors . length === 0 && this . compositeBar . getPinnedComposites ( ) . length > 1 ) {
346+ const viewContainerModel = this . viewDescriptorService . getViewContainerModel ( viewContainer ) ;
347+ if ( viewContainerModel . activeViewDescriptors . length === 0 && this . compositeBar . getPinnedComposites ( ) . length > 1 ) {
325348 this . hideComposite ( panelDescriptor . id ) ; // Update the composite bar by hiding
326349 }
327350 }
@@ -540,28 +563,6 @@ export class PanelPart extends CompositePart<Panel> implements IPanelService {
540563 return false ;
541564 }
542565
543- protected onTitleAreaUpdate ( compositeId : string ) : void {
544- super . onTitleAreaUpdate ( compositeId ) ;
545-
546- const activePanel = this . getActivePanel ( ) ;
547- const panel = this . createComposite ( compositeId , activePanel ?. getId ( ) === compositeId ) ;
548-
549- if ( panel ) {
550- const compositeActions = this . compositeActions . get ( compositeId ) ;
551- if ( compositeActions ) {
552- compositeActions . activityAction . setActivity ( {
553- id : compositeActions . activityAction . id ,
554- name : panel . getTitle ( ) || compositeActions . activityAction . label
555- } ) ;
556-
557- compositeActions . pinnedAction . setActivity ( {
558- id : compositeActions . activityAction . id ,
559- name : panel . getTitle ( ) || compositeActions . activityAction . label
560- } ) ;
561- }
562- }
563- }
564-
565566 private getToolbarWidth ( ) : number {
566567 const activePanel = this . getActivePanel ( ) ;
567568 if ( ! activePanel || ! this . toolBar ) {
@@ -609,8 +610,11 @@ export class PanelPart extends CompositePart<Panel> implements IPanelService {
609610
610611 const compositeItems = this . compositeBar . getCompositeBarItems ( ) ;
611612 for ( const compositeItem of compositeItems ) {
612- const activityAction = this . getCompositeActions ( compositeItem . id ) . activityAction ;
613- state . push ( { id : compositeItem . id , name : activityAction . label , pinned : compositeItem . pinned , order : compositeItem . order , visible : compositeItem . visible } ) ;
613+ const viewContainer = this . getViewContainer ( compositeItem . id ) ;
614+ if ( viewContainer ) {
615+ const viewContainerModel = this . viewDescriptorService . getViewContainerModel ( viewContainer ) ;
616+ state . push ( { id : compositeItem . id , name : viewContainerModel . title , pinned : compositeItem . pinned , order : compositeItem . order , visible : compositeItem . visible } ) ;
617+ }
614618 }
615619
616620 this . cachedPanelsValue = JSON . stringify ( state ) ;
0 commit comments