@@ -19,6 +19,7 @@ import { Viewlet, ViewletRegistry, Extensions } from 'vs/workbench/browser/viewl
1919import { ITree } from 'vs/base/parts/tree/browser/tree' ;
2020import { DelayedDragHandler } from 'vs/base/browser/dnd' ;
2121import { ToolBar } from 'vs/base/browser/ui/toolbar/toolbar' ;
22+ import { IExtensionService } from 'vs/platform/extensions/common/extensions' ;
2223import { IKeybindingService } from 'vs/platform/keybinding/common/keybinding' ;
2324import { IContextMenuService } from 'vs/platform/contextview/browser/contextView' ;
2425import { AbstractCollapsibleView , CollapsibleState , IView as IBaseView , SplitView , ViewSizing } from 'vs/base/browser/ui/splitview/splitview' ;
@@ -310,6 +311,7 @@ export class ComposedViewsViewlet extends Viewlet {
310311
311312 private readonly viewsContextKeys : Set < string > = new Set < string > ( ) ;
312313 private readonly viewsStates : Map < string , IViewState > ;
314+ private areExtensionsReady : boolean = false ;
313315
314316 constructor (
315317 id : string ,
@@ -321,7 +323,8 @@ export class ComposedViewsViewlet extends Viewlet {
321323 @IThemeService themeService : IThemeService ,
322324 @IWorkspaceContextService protected contextService : IWorkspaceContextService ,
323325 @IContextKeyService protected contextKeyService : IContextKeyService ,
324- @IContextMenuService private contextMenuService : IContextMenuService
326+ @IContextMenuService private contextMenuService : IContextMenuService ,
327+ @IExtensionService extensionService : IExtensionService
325328 ) {
326329 super ( id , telemetryService , themeService ) ;
327330
@@ -332,6 +335,11 @@ export class ComposedViewsViewlet extends Viewlet {
332335 this . _register ( ViewsRegistry . onViewsRegistered ( ( ) => this . onViewDescriptorsChanged ( ) ) ) ;
333336 this . _register ( ViewsRegistry . onViewsDeregistered ( ( ) => this . onViewDescriptorsChanged ( ) ) ) ;
334337 this . _register ( contextKeyService . onDidChangeContext ( keys => this . onContextChanged ( keys ) ) ) ;
338+
339+ extensionService . onReady ( ) . then ( ( ) => {
340+ this . areExtensionsReady = true ;
341+ this . onViewsUpdated ( ) ;
342+ } ) ;
335343 }
336344
337345 public create ( parent : Builder ) : TPromise < void > {
@@ -351,22 +359,22 @@ export class ComposedViewsViewlet extends Viewlet {
351359
352360 public getTitle ( ) : string {
353361 let title = Registry . as < ViewletRegistry > ( Extensions . Viewlets ) . getViewlet ( this . getId ( ) ) . name ;
354- if ( this . views . length === 1 ) {
362+ if ( this . hasSingleView ( ) ) {
355363 title += ': ' + this . views [ 0 ] . name ;
356364 }
357365 return title ;
358366 }
359367
360368 public getActions ( ) : IAction [ ] {
361- if ( this . views . length === 1 ) {
369+ if ( this . hasSingleView ( ) ) {
362370 return this . views [ 0 ] . getActions ( ) ;
363371 }
364372 return [ ] ;
365373 }
366374
367375 public getSecondaryActions ( ) : IAction [ ] {
368376 let actions = [ ] ;
369- if ( this . views . length === 1 ) {
377+ if ( this . hasSingleView ( ) ) {
370378 actions = this . views [ 0 ] . getSecondaryActions ( ) ;
371379 }
372380
@@ -572,10 +580,12 @@ export class ComposedViewsViewlet extends Viewlet {
572580 }
573581
574582 private onViewsUpdated ( ) : TPromise < void > {
575- if ( this . views . length === 1 ) {
576- this . views [ 0 ] . hideHeader ( ) ;
577- if ( ! this . views [ 0 ] . isExpanded ( ) ) {
578- this . views [ 0 ] . expand ( ) ;
583+ if ( this . hasSingleView ( ) ) {
584+ if ( this . views [ 0 ] ) {
585+ this . views [ 0 ] . hideHeader ( ) ;
586+ if ( ! this . views [ 0 ] . isExpanded ( ) ) {
587+ this . views [ 0 ] . expand ( ) ;
588+ }
579589 }
580590 } else {
581591 for ( const view of this . views ) {
@@ -593,6 +603,17 @@ export class ComposedViewsViewlet extends Viewlet {
593603 return this . setVisible ( this . isVisible ( ) ) ;
594604 }
595605
606+ private hasSingleView ( ) : boolean {
607+ if ( this . views . length > 1 ) {
608+ return false ;
609+ }
610+ if ( ViewLocation . getContributedViewLocation ( this . location . id ) && ! this . areExtensionsReady ) {
611+ // Checks in cache so that view do not jump. See #29609
612+ return this . viewsStates . size === 1 ;
613+ }
614+ return true ;
615+ }
616+
596617 private getViewDescriptorsFromRegistry ( ) : IViewDescriptor [ ] {
597618 return ViewsRegistry . getViews ( this . location )
598619 . sort ( ( a , b ) => {
@@ -610,8 +631,10 @@ export class ComposedViewsViewlet extends Viewlet {
610631 const viewsStates = { } ;
611632 this . viewsStates . forEach ( ( viewState , id ) => {
612633 const view = this . getView ( id ) ;
613- viewState = view ? this . createViewState ( view ) : viewState ;
614- viewsStates [ id ] = { size : viewState . size , collapsed : viewState . collapsed , isHidden : viewState . isHidden } ;
634+ if ( view ) {
635+ viewState = view ? this . createViewState ( view ) : viewState ;
636+ viewsStates [ id ] = { size : viewState . size , collapsed : viewState . collapsed , isHidden : viewState . isHidden } ;
637+ }
615638 } ) ;
616639
617640 this . storageService . store ( this . viewletStateStorageId , JSON . stringify ( viewsStates ) , this . contextService . hasWorkspace ( ) ? StorageScope . WORKSPACE : StorageScope . GLOBAL ) ;
0 commit comments