@@ -39,6 +39,7 @@ import { ViewMenuActions } from 'vs/workbench/browser/parts/views/viewMenuAction
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 ;
@@ -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 viewDescriptors = this . viewDescriptorService . getViewDescriptors ( viewContainer ) ;
215+ this . onDidChangeActiveViews ( panel , viewDescriptors , viewContainer . hideIfEmpty ) ;
216+
217+ const disposables = new DisposableStore ( ) ;
218+ disposables . add ( viewDescriptors . onDidChangeActiveViews ( ( ) => this . onDidChangeActiveViews ( panel , viewDescriptors , viewContainer . hideIfEmpty ) ) ) ;
219+ disposables . add ( viewDescriptors . onDidChangeViews ( ( ) => this . onDidUpdateViews ( panel , viewDescriptors ) ) ) ;
220+ disposables . add ( viewDescriptors . onDidMove ( ( ) => this . onDidUpdateViews ( panel , viewDescriptors ) ) ) ;
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 , viewDescriptors : IViewDescriptorCollection ) : void {
246+ const activity : IActivity = {
247+ id : panel . id ,
248+ name : viewDescriptors . getTitle ( ) ,
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 : IViewDescriptorCollection ) : void {
261+ this . updateActivity ( panel , viewDescriptors ) ;
262+ }
263+
264+ private onDidChangeActiveViews ( panel : PanelDescriptor , viewDescriptors : IViewDescriptorCollection , 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 }
@@ -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 ) {
0 commit comments