33 * Licensed under the MIT License. See License.txt in the project root for license information.
44 *--------------------------------------------------------------------------------------------*/
55
6- import { ViewContainerLocation , IViewDescriptorService , ViewContainer , IViewsRegistry , IViewContainersRegistry , IViewDescriptor , Extensions as ViewExtensions } from 'vs/workbench/common/views' ;
6+ import { ViewContainerLocation , IViewDescriptorService , ViewContainer , IViewsRegistry , IViewContainersRegistry , IViewDescriptor , Extensions as ViewExtensions , ViewVisibilityState } from 'vs/workbench/common/views' ;
77import { IContextKey , RawContextKey , IContextKeyService , ContextKeyExpr } from 'vs/platform/contextkey/common/contextkey' ;
88import { IStorageService , StorageScope , IWorkspaceStorageChangeEvent } from 'vs/platform/storage/common/storage' ;
99import { IExtensionService } from 'vs/workbench/services/extensions/common/extensions' ;
@@ -166,7 +166,7 @@ export class ViewDescriptorService extends Disposable implements IViewDescriptor
166166 // This is needed when statically-registered views are moved to
167167 // other statically registered containers as they will both try to add on startup
168168 const viewsToAdd = containerData . views . filter ( view => this . getViewContainerModel ( viewContainer ) . allViewDescriptors . filter ( vd => vd . id === view . id ) . length === 0 ) ;
169- this . addViews ( viewContainer , viewsToAdd ) ;
169+ this . addViews ( viewContainer , viewsToAdd , ViewVisibilityState . Default ) ;
170170 }
171171 }
172172
@@ -197,7 +197,7 @@ export class ViewDescriptorService extends Disposable implements IViewDescriptor
197197 const viewContainer = this . viewsRegistry . getViewContainer ( viewId ) ;
198198 const viewDescriptor = this . getViewDescriptorById ( viewId ) ;
199199 if ( viewContainer && viewDescriptor ) {
200- this . addViews ( viewContainer , [ viewDescriptor ] ) ;
200+ this . addViews ( viewContainer , [ viewDescriptor ] , ViewVisibilityState . Default ) ;
201201 }
202202 }
203203 }
@@ -330,7 +330,7 @@ export class ViewDescriptorService extends Disposable implements IViewDescriptor
330330 this . moveViewsToContainer ( [ view ] , container ) ;
331331 }
332332
333- moveViewsToContainer ( views : IViewDescriptor [ ] , viewContainer : ViewContainer ) : void {
333+ moveViewsToContainer ( views : IViewDescriptor [ ] , viewContainer : ViewContainer , visibilityState ?: ViewVisibilityState ) : void {
334334 if ( ! views . length ) {
335335 return ;
336336 }
@@ -339,7 +339,7 @@ export class ViewDescriptorService extends Disposable implements IViewDescriptor
339339 const to = viewContainer ;
340340
341341 if ( from && to && from !== to ) {
342- this . moveViews ( views , from , to ) ;
342+ this . moveViews ( views , from , to , visibilityState ) ;
343343 this . cleanUpViewContainer ( from . id ) ;
344344 }
345345 }
@@ -376,9 +376,9 @@ export class ViewDescriptorService extends Disposable implements IViewDescriptor
376376 return this . isGeneratedContainerId ( viewContainerId ) && ! this . cachedViewContainerInfo . has ( viewContainerId ) ;
377377 }
378378
379- private moveViews ( views : IViewDescriptor [ ] , from : ViewContainer , to : ViewContainer , skipCacheUpdate ?: boolean ) : void {
379+ private moveViews ( views : IViewDescriptor [ ] , from : ViewContainer , to : ViewContainer , visibilityState : ViewVisibilityState = ViewVisibilityState . Expand ) : void {
380380 this . removeViews ( from , views ) ;
381- this . addViews ( to , views , true ) ;
381+ this . addViews ( to , views , visibilityState ) ;
382382
383383 const oldLocation = this . getViewContainerLocation ( from ) ;
384384 const newLocation = this . getViewContainerLocation ( to ) ;
@@ -389,46 +389,44 @@ export class ViewDescriptorService extends Disposable implements IViewDescriptor
389389
390390 this . _onDidChangeContainer . fire ( { views, from, to } ) ;
391391
392- if ( ! skipCacheUpdate ) {
393- this . saveViewPositionsToCache ( ) ;
394-
395- const containerToString = ( container : ViewContainer ) : string => {
396- if ( container . id . startsWith ( ViewDescriptorService . COMMON_CONTAINER_ID_PREFIX ) ) {
397- return 'custom' ;
398- }
399-
400- if ( ! container . extensionId ) {
401- return container . id ;
402- }
403-
404- return 'extension' ;
405- } ;
392+ this . saveViewPositionsToCache ( ) ;
406393
407- // Log on cache update to avoid duplicate events in other windows
408- const viewCount = views . length ;
409- const fromContainer = containerToString ( from ) ;
410- const toContainer = containerToString ( to ) ;
411- const fromLocation = oldLocation === ViewContainerLocation . Panel ? 'panel' : 'sidebar' ;
412- const toLocation = newLocation === ViewContainerLocation . Panel ? 'panel' : 'sidebar' ;
413-
414- interface ViewDescriptorServiceMoveViewsEvent {
415- viewCount : number ;
416- fromContainer : string ;
417- toContainer : string ;
418- fromLocation : string ;
419- toLocation : string ;
394+ const containerToString = ( container : ViewContainer ) : string => {
395+ if ( container . id . startsWith ( ViewDescriptorService . COMMON_CONTAINER_ID_PREFIX ) ) {
396+ return 'custom' ;
420397 }
421398
422- type ViewDescriptorServiceMoveViewsClassification = {
423- viewCount : { classification : 'SystemMetaData' , purpose : 'FeatureInsight' } ;
424- fromContainer : { classification : 'SystemMetaData' , purpose : 'FeatureInsight' } ;
425- toContainer : { classification : 'SystemMetaData' , purpose : 'FeatureInsight' } ;
426- fromLocation : { classification : 'SystemMetaData' , purpose : 'FeatureInsight' } ;
427- toLocation : { classification : 'SystemMetaData' , purpose : 'FeatureInsight' } ;
428- } ;
399+ if ( ! container . extensionId ) {
400+ return container . id ;
401+ }
429402
430- this . telemetryService . publicLog2 < ViewDescriptorServiceMoveViewsEvent , ViewDescriptorServiceMoveViewsClassification > ( 'viewDescriptorService.moveViews' , { viewCount, fromContainer, toContainer, fromLocation, toLocation } ) ;
403+ return 'extension' ;
404+ } ;
405+
406+ // Log on cache update to avoid duplicate events in other windows
407+ const viewCount = views . length ;
408+ const fromContainer = containerToString ( from ) ;
409+ const toContainer = containerToString ( to ) ;
410+ const fromLocation = oldLocation === ViewContainerLocation . Panel ? 'panel' : 'sidebar' ;
411+ const toLocation = newLocation === ViewContainerLocation . Panel ? 'panel' : 'sidebar' ;
412+
413+ interface ViewDescriptorServiceMoveViewsEvent {
414+ viewCount : number ;
415+ fromContainer : string ;
416+ toContainer : string ;
417+ fromLocation : string ;
418+ toLocation : string ;
431419 }
420+
421+ type ViewDescriptorServiceMoveViewsClassification = {
422+ viewCount : { classification : 'SystemMetaData' , purpose : 'FeatureInsight' } ;
423+ fromContainer : { classification : 'SystemMetaData' , purpose : 'FeatureInsight' } ;
424+ toContainer : { classification : 'SystemMetaData' , purpose : 'FeatureInsight' } ;
425+ fromLocation : { classification : 'SystemMetaData' , purpose : 'FeatureInsight' } ;
426+ toLocation : { classification : 'SystemMetaData' , purpose : 'FeatureInsight' } ;
427+ } ;
428+
429+ this . telemetryService . publicLog2 < ViewDescriptorServiceMoveViewsEvent , ViewDescriptorServiceMoveViewsClassification > ( 'viewDescriptorService.moveViews' , { viewCount, fromContainer, toContainer, fromLocation, toLocation } ) ;
432430 }
433431
434432 private cleanUpViewContainer ( viewContainerId : string ) : void {
@@ -699,7 +697,7 @@ export class ViewDescriptorService extends Disposable implements IViewDescriptor
699697 // Add views that were registered prior to this view container
700698 const viewsToRegister = this . getViewsByContainer ( viewContainer ) . filter ( view => this . getDefaultContainerById ( view . id ) !== viewContainer ) ;
701699 if ( viewsToRegister . length ) {
702- this . addViews ( viewContainer , viewsToRegister ) ;
700+ this . addViews ( viewContainer , viewsToRegister , ViewVisibilityState . Default ) ;
703701 this . contextKeyService . bufferChangeEvents ( ( ) => {
704702 viewsToRegister . forEach ( viewDescriptor => this . getOrCreateMovableViewContextKey ( viewDescriptor ) . set ( ! ! viewDescriptor . canMoveView ) ) ;
705703 } ) ;
@@ -751,7 +749,7 @@ export class ViewDescriptorService extends Disposable implements IViewDescriptor
751749 } ) ;
752750 }
753751
754- private addViews ( container : ViewContainer , views : IViewDescriptor [ ] , expandViews ?: boolean ) : void {
752+ private addViews ( container : ViewContainer , views : IViewDescriptor [ ] , visibilityState : ViewVisibilityState = ViewVisibilityState . Default ) : void {
755753 // Update in memory cache
756754 this . contextKeyService . bufferChangeEvents ( ( ) => {
757755 views . forEach ( view => {
@@ -760,7 +758,13 @@ export class ViewDescriptorService extends Disposable implements IViewDescriptor
760758 } ) ;
761759 } ) ;
762760
763- this . getViewContainerModel ( container ) . add ( views . map ( view => { return { viewDescriptor : view , collapsed : expandViews ? false : undefined , visible : expandViews } ; } ) ) ;
761+ this . getViewContainerModel ( container ) . add ( views . map ( view => {
762+ return {
763+ viewDescriptor : view ,
764+ collapsed : visibilityState === ViewVisibilityState . Default ? undefined : false ,
765+ visible : visibilityState === ViewVisibilityState . Default ? undefined : true
766+ } ;
767+ } ) ) ;
764768 }
765769
766770 private removeViews ( container : ViewContainer , views : IViewDescriptor [ ] ) : void {
0 commit comments