@@ -14,6 +14,7 @@ import { ViewletDescriptor, ViewletRegistry, Extensions as ViewletExtensions } f
1414import { IProgressService } from 'vs/platform/progress/common/progress' ;
1515import { IContextKeyService , RawContextKey , IContextKey } from 'vs/platform/contextkey/common/contextkey' ;
1616import { dispose , IDisposable } from 'vs/base/common/lifecycle' ;
17+ import { IExtensionService } from 'vs/workbench/services/extensions/common/extensions' ;
1718
1819const ActiveViewletContextId = 'activeViewlet' ;
1920export const ActiveViewletContext = new RawContextKey < string > ( ActiveViewletContextId , '' ) ;
@@ -25,7 +26,6 @@ export class ViewletService implements IViewletService {
2526 private sidebarPart : SidebarPart ;
2627 private viewletRegistry : ViewletRegistry ;
2728
28- private extensionViewletsLoaded : TPromise < void > ;
2929 private activeViewletContextKey : IContextKey < string > ;
3030 private _onDidViewletEnable = new Emitter < { id : string , enabled : boolean } > ( ) ;
3131 private disposables : IDisposable [ ] = [ ] ;
@@ -37,7 +37,8 @@ export class ViewletService implements IViewletService {
3737
3838 constructor (
3939 sidebarPart : SidebarPart ,
40- @IContextKeyService contextKeyService : IContextKeyService
40+ @IContextKeyService contextKeyService : IContextKeyService ,
41+ @IExtensionService private extensionService : IExtensionService
4142 ) {
4243 this . sidebarPart = sidebarPart ;
4344 this . viewletRegistry = Registry . as < ViewletRegistry > ( ViewletExtensions . Viewlets ) ;
@@ -69,23 +70,11 @@ export class ViewletService implements IViewletService {
6970 }
7071
7172 public openViewlet ( id : string , focus ?: boolean ) : TPromise < IViewlet > {
72-
73- // Built in viewlets do not need to wait for extensions to be loaded
74- const builtInViewletIds = this . getBuiltInViewlets ( ) . map ( v => v . id ) ;
75- const isBuiltInViewlet = builtInViewletIds . indexOf ( id ) !== - 1 ;
76- if ( isBuiltInViewlet ) {
73+ if ( this . getViewlet ( id ) ) {
7774 return this . sidebarPart . openViewlet ( id , focus ) ;
7875 }
79-
80- // Extension viewlets need to be loaded first which can take time
81- return this . extensionViewletsLoaded . then ( ( ) => {
82- if ( this . viewletRegistry . getViewlet ( id ) ) {
83- return this . sidebarPart . openViewlet ( id , focus ) ;
84- }
85-
86- // Fallback to default viewlet if extension viewlet is still not found (e.g. uninstalled)
87- return this . sidebarPart . openViewlet ( this . getDefaultViewletId ( ) , focus ) ;
88- } ) ;
76+ return this . extensionService . whenInstalledExtensionsRegistered ( )
77+ . then ( ( ) => this . sidebarPart . openViewlet ( id , focus ) ) ;
8978 }
9079
9180 public getActiveViewlet ( ) : IViewlet {
0 commit comments