@@ -105,8 +105,6 @@ import { WorkbenchContextKeysHandler } from 'vs/workbench/browser/contextkeys';
105105import { ServicesAccessor } from 'vs/editor/browser/editorExtensions' ;
106106
107107// import@node
108- import { BackupFileService , InMemoryBackupFileService } from 'vs/workbench/services/backup/node/backupFileService' ;
109- import { WorkspaceService } from 'vs/workbench/services/configuration/node/configurationService' ;
110108import { getDelayedChannel } from 'vs/base/parts/ipc/node/ipc' ;
111109import { connect as connectNet } from 'vs/base/parts/ipc/node/ipc.net' ;
112110import { DialogChannel } from 'vs/platform/dialogs/node/dialogIpc' ;
@@ -190,13 +188,13 @@ export class Workbench extends Disposable implements IPartService {
190188 private editorService : EditorService ;
191189 private editorGroupService : IEditorGroupsService ;
192190 private contextViewService : ContextViewService ;
193- private backupFileService : IBackupFileService ;
194191 private windowService : IWindowService ;
195- private lifecycleService : LifecycleService ;
192+ private lifecycleService : ILifecycleService ;
193+
196194 private instantiationService : IInstantiationService ;
197195 private contextService : IWorkspaceContextService ;
198196 private storageService : IStorageService ;
199- private configurationService : WorkspaceService ;
197+ private configurationService : IConfigurationService ;
200198 private environmentService : IEnvironmentService ;
201199 private logService : ILogService ;
202200 private windowsService : IWindowsService ;
@@ -221,7 +219,7 @@ export class Workbench extends Disposable implements IPartService {
221219 @IInstantiationService instantiationService : IInstantiationService ,
222220 @IWorkspaceContextService contextService : IWorkspaceContextService ,
223221 @IStorageService storageService : IStorageService ,
224- @IConfigurationService configurationService : WorkspaceService ,
222+ @IConfigurationService configurationService : IConfigurationService ,
225223 @IEnvironmentService environmentService : IEnvironmentService ,
226224 @ILogService logService : ILogService ,
227225 @IWindowsService windowsService : IWindowsService
@@ -333,7 +331,7 @@ export class Workbench extends Disposable implements IPartService {
333331 this . registerLayoutListeners ( ) ;
334332
335333 // Layout State
336- this . initLayoutState ( ) ;
334+ this . instantiationService . invokeFunction ( accessor => this . initLayoutState ( accessor ) ) ;
337335
338336 // Render Workbench
339337 this . renderWorkbench ( ) ;
@@ -525,14 +523,6 @@ export class Workbench extends Disposable implements IPartService {
525523 // History
526524 serviceCollection . set ( IHistoryService , new SyncDescriptor ( HistoryService ) ) ;
527525
528- // Backup File Service
529- if ( this . configuration . backupPath ) {
530- this . backupFileService = this . instantiationService . createInstance ( BackupFileService , this . configuration . backupPath ) ;
531- } else {
532- this . backupFileService = new InMemoryBackupFileService ( ) ;
533- }
534- serviceCollection . set ( IBackupFileService , this . backupFileService ) ;
535-
536526 // Quick open service (quick open controller)
537527 this . quickOpen = this . instantiationService . createInstance ( QuickOpenController ) ;
538528 serviceCollection . set ( IQuickOpenService , this . quickOpen ) ;
@@ -561,12 +551,20 @@ export class Workbench extends Disposable implements IPartService {
561551 this . instantiationService . invokeFunction ( accessor => {
562552 const fileService = accessor . get ( IFileService ) ;
563553 const instantiationService = accessor . get ( IInstantiationService ) ;
564- const themeService = accessor . get ( IWorkbenchThemeService ) as WorkbenchThemeService ;
554+ const configurationService = accessor . get ( IConfigurationService ) as any ;
555+ const themeService = accessor . get ( IWorkbenchThemeService ) as any ;
565556
566- this . configurationService . acquireFileService ( fileService ) ;
567- this . configurationService . acquireInstantiationService ( instantiationService ) ;
557+ if ( typeof configurationService . acquireFileService === 'function' ) {
558+ configurationService . acquireFileService ( fileService ) ;
559+ }
560+
561+ if ( typeof configurationService . acquireInstantiationService === 'function' ) {
562+ configurationService . acquireInstantiationService ( instantiationService ) ;
563+ }
568564
569- themeService . acquireFileService ( fileService ) ;
565+ if ( typeof themeService . acquireFileService === 'function' ) {
566+ themeService . acquireFileService ( fileService ) ;
567+ }
570568 } ) ;
571569 }
572570
@@ -785,7 +783,7 @@ export class Workbench extends Disposable implements IPartService {
785783 }
786784
787785 private whenStarted ( accessor : ServicesAccessor , error ?: Error ) : void {
788- const lifecycleService = accessor . get ( ILifecycleService ) as LifecycleService ;
786+ const lifecycleService = accessor . get ( ILifecycleService ) ;
789787
790788 this . restored = true ;
791789
@@ -1020,31 +1018,36 @@ export class Workbench extends Disposable implements IPartService {
10201018 }
10211019 }
10221020
1023- private initLayoutState ( ) : void {
1021+ private initLayoutState ( accessor : ServicesAccessor ) : void {
1022+ const configurationService = accessor . get ( IConfigurationService ) ;
1023+ const storageService = accessor . get ( IStorageService ) ;
1024+ const lifecycleService = accessor . get ( ILifecycleService ) ;
1025+ const contextService = accessor . get ( IWorkspaceContextService ) ;
1026+ const environmentService = accessor . get ( IEnvironmentService ) ;
10241027
10251028 // Fullscreen
10261029 this . state . fullscreen = isFullscreen ( ) ;
10271030
10281031 // Menubar visibility
1029- this . state . menuBar . visibility = this . configurationService . getValue < MenuBarVisibility > ( Settings . MENUBAR_VISIBLE ) ;
1032+ this . state . menuBar . visibility = configurationService . getValue < MenuBarVisibility > ( Settings . MENUBAR_VISIBLE ) ;
10301033
10311034 // Activity bar visibility
1032- this . state . activityBar . hidden = ! this . configurationService . getValue < string > ( Settings . ACTIVITYBAR_VISIBLE ) ;
1035+ this . state . activityBar . hidden = ! configurationService . getValue < string > ( Settings . ACTIVITYBAR_VISIBLE ) ;
10331036
10341037 // Sidebar visibility
1035- this . state . sideBar . hidden = this . storageService . getBoolean ( Storage . SIDEBAR_HIDDEN , StorageScope . WORKSPACE , this . contextService . getWorkbenchState ( ) === WorkbenchState . EMPTY ) ;
1038+ this . state . sideBar . hidden = storageService . getBoolean ( Storage . SIDEBAR_HIDDEN , StorageScope . WORKSPACE , contextService . getWorkbenchState ( ) === WorkbenchState . EMPTY ) ;
10361039
10371040 // Sidebar position
1038- this . state . sideBar . position = ( this . configurationService . getValue < string > ( Settings . SIDEBAR_POSITION ) === 'right' ) ? Position . RIGHT : Position . LEFT ;
1041+ this . state . sideBar . position = ( configurationService . getValue < string > ( Settings . SIDEBAR_POSITION ) === 'right' ) ? Position . RIGHT : Position . LEFT ;
10391042
10401043 // Sidebar viewlet
10411044 if ( ! this . state . sideBar . hidden ) {
10421045 const viewletRegistry = Registry . as < ViewletRegistry > ( ViewletExtensions . Viewlets ) ;
10431046
10441047 // Only restore last viewlet if window was reloaded or we are in development mode
10451048 let viewletToRestore : string ;
1046- if ( ! this . environmentService . isBuilt || this . lifecycleService . startupKind === StartupKind . ReloadedWindow ) {
1047- viewletToRestore = this . storageService . get ( SidebarPart . activeViewletSettingsKey , StorageScope . WORKSPACE , viewletRegistry . getDefaultViewletId ( ) ) ;
1049+ if ( ! environmentService . isBuilt || lifecycleService . startupKind === StartupKind . ReloadedWindow ) {
1050+ viewletToRestore = storageService . get ( SidebarPart . activeViewletSettingsKey , StorageScope . WORKSPACE , viewletRegistry . getDefaultViewletId ( ) ) ;
10481051 } else {
10491052 viewletToRestore = viewletRegistry . getDefaultViewletId ( ) ;
10501053 }
@@ -1057,13 +1060,13 @@ export class Workbench extends Disposable implements IPartService {
10571060 }
10581061
10591062 // Editor centered layout
1060- this . state . editor . restoreCentered = this . storageService . getBoolean ( Storage . CENTERED_LAYOUT_ENABLED , StorageScope . WORKSPACE , false ) ;
1063+ this . state . editor . restoreCentered = storageService . getBoolean ( Storage . CENTERED_LAYOUT_ENABLED , StorageScope . WORKSPACE , false ) ;
10611064
10621065 // Editors to open
1063- this . state . editor . editorsToOpen = this . resolveEditorsToOpen ( ) ;
1066+ this . state . editor . editorsToOpen = this . resolveEditorsToOpen ( accessor ) ;
10641067
10651068 // Panel visibility
1066- this . state . panel . hidden = this . storageService . getBoolean ( Storage . PANEL_HIDDEN , StorageScope . WORKSPACE , true ) ;
1069+ this . state . panel . hidden = storageService . getBoolean ( Storage . PANEL_HIDDEN , StorageScope . WORKSPACE , true ) ;
10671070
10681071 // Panel position
10691072 this . updatePanelPosition ( ) ;
@@ -1072,7 +1075,7 @@ export class Workbench extends Disposable implements IPartService {
10721075 if ( ! this . state . panel . hidden ) {
10731076 const panelRegistry = Registry . as < PanelRegistry > ( PanelExtensions . Panels ) ;
10741077
1075- let panelToRestore = this . storageService . get ( PanelPart . activePanelSettingsKey , StorageScope . WORKSPACE , panelRegistry . getDefaultPanelId ( ) ) ;
1078+ let panelToRestore = storageService . get ( PanelPart . activePanelSettingsKey , StorageScope . WORKSPACE , panelRegistry . getDefaultPanelId ( ) ) ;
10761079 if ( ! panelRegistry . hasPanel ( panelToRestore ) ) {
10771080 panelToRestore = panelRegistry . getDefaultPanelId ( ) ; // fallback to default if panel is unknown
10781081 }
@@ -1085,19 +1088,24 @@ export class Workbench extends Disposable implements IPartService {
10851088 }
10861089
10871090 // Statusbar visibility
1088- this . state . statusBar . hidden = ! this . configurationService . getValue < string > ( Settings . STATUSBAR_VISIBLE ) ;
1091+ this . state . statusBar . hidden = ! configurationService . getValue < string > ( Settings . STATUSBAR_VISIBLE ) ;
10891092
10901093 // Zen mode enablement
1091- this . state . zenMode . restore = this . storageService . getBoolean ( Storage . ZEN_MODE_ENABLED , StorageScope . WORKSPACE , false ) && this . configurationService . getValue ( Settings . ZEN_MODE_RESTORE ) ;
1094+ this . state . zenMode . restore = storageService . getBoolean ( Storage . ZEN_MODE_ENABLED , StorageScope . WORKSPACE , false ) && configurationService . getValue ( Settings . ZEN_MODE_RESTORE ) ;
10921095 }
10931096
1094- private resolveEditorsToOpen ( ) : Promise < IResourceEditor [ ] > | IResourceEditor [ ] {
1097+ private resolveEditorsToOpen ( accessor : ServicesAccessor ) : Promise < IResourceEditor [ ] > | IResourceEditor [ ] {
1098+ const configuration = accessor . get ( IWindowService ) . getConfiguration ( ) ;
1099+ const configurationService = accessor . get ( IConfigurationService ) ;
1100+ const contextService = accessor . get ( IWorkspaceContextService ) ;
1101+ const editorGroupService = accessor . get ( IEditorGroupsService ) ;
1102+ const backupFileService = accessor . get ( IBackupFileService ) ;
10951103
10961104 // Files to open, diff or create
10971105 if ( this . hasInitialFilesToOpen ( ) ) {
10981106
10991107 // Files to diff is exclusive
1100- const filesToDiff = this . toInputs ( this . configuration . filesToDiff , false ) ;
1108+ const filesToDiff = this . toInputs ( configuration . filesToDiff , false ) ;
11011109 if ( filesToDiff && filesToDiff . length === 2 ) {
11021110 return [ < IResourceDiffInput > {
11031111 leftResource : filesToDiff [ 0 ] . resource ,
@@ -1107,21 +1115,21 @@ export class Workbench extends Disposable implements IPartService {
11071115 } ] ;
11081116 }
11091117
1110- const filesToCreate = this . toInputs ( this . configuration . filesToCreate , true ) ;
1111- const filesToOpen = this . toInputs ( this . configuration . filesToOpen , false ) ;
1118+ const filesToCreate = this . toInputs ( configuration . filesToCreate , true ) ;
1119+ const filesToOpen = this . toInputs ( configuration . filesToOpen , false ) ;
11121120
11131121 // Otherwise: Open/Create files
11141122 return [ ...filesToOpen , ...filesToCreate ] ;
11151123 }
11161124
11171125 // Empty workbench
1118- else if ( this . contextService . getWorkbenchState ( ) === WorkbenchState . EMPTY && this . configurationService . inspect ( 'workbench.startupEditor' ) . value === 'newUntitledFile' ) {
1119- const isEmpty = this . editorGroupService . count === 1 && this . editorGroupService . activeGroup . count === 0 ;
1126+ else if ( contextService . getWorkbenchState ( ) === WorkbenchState . EMPTY && configurationService . inspect ( 'workbench.startupEditor' ) . value === 'newUntitledFile' ) {
1127+ const isEmpty = editorGroupService . count === 1 && editorGroupService . activeGroup . count === 0 ;
11201128 if ( ! isEmpty ) {
11211129 return [ ] ; // do not open any empty untitled file if we restored editors from previous session
11221130 }
11231131
1124- return this . backupFileService . hasBackups ( ) . then ( hasBackups => {
1132+ return backupFileService . hasBackups ( ) . then ( hasBackups => {
11251133 if ( hasBackups ) {
11261134 return [ ] ; // do not open any empty untitled file if we have backups to restore
11271135 }
0 commit comments