@@ -220,6 +220,7 @@ export class WorkspaceEditingService implements IWorkspaceEditingService {
220220 private async doAddFolders ( foldersToAdd : IWorkspaceFolderCreationData [ ] , index ?: number , donotNotifyError : boolean = false ) : Promise < void > {
221221 const state = this . contextService . getWorkbenchState ( ) ;
222222 if ( this . environmentService . configuration . remoteAuthority ) {
223+
223224 // Do not allow workspace folders with scheme different than the current remote scheme
224225 const schemas = this . contextService . getWorkspace ( ) . folders . map ( f => f . uri . scheme ) ;
225226 if ( schemas . length && foldersToAdd . some ( f => schemas . indexOf ( f . uri . scheme ) === - 1 ) ) {
@@ -286,31 +287,34 @@ export class WorkspaceEditingService implements IWorkspaceEditingService {
286287 if ( path && ! await this . isValidTargetWorkspacePath ( path ) ) {
287288 return ;
288289 }
290+
289291 const remoteAuthority = this . environmentService . configuration . remoteAuthority ;
290292 const untitledWorkspace = await this . workspaceService . createUntitledWorkspace ( folders , remoteAuthority ) ;
291293 if ( path ) {
292294 await this . saveWorkspaceAs ( untitledWorkspace , path ) ;
293295 } else {
294296 path = untitledWorkspace . configPath ;
295297 }
298+
296299 return this . enterWorkspace ( path ) ;
297300 }
298301
299302 async saveAndEnterWorkspace ( path : URI ) : Promise < void > {
300303 if ( ! await this . isValidTargetWorkspacePath ( path ) ) {
301304 return ;
302305 }
306+
303307 const workspaceIdentifier = this . getCurrentWorkspaceIdentifier ( ) ;
304308 if ( ! workspaceIdentifier ) {
305309 return ;
306310 }
311+
307312 await this . saveWorkspaceAs ( workspaceIdentifier , path ) ;
308313
309314 return this . enterWorkspace ( path ) ;
310315 }
311316
312317 async isValidTargetWorkspacePath ( path : URI ) : Promise < boolean > {
313-
314318 const windows = await this . windowsService . getWindows ( ) ;
315319
316320 // Prevent overwriting a workspace that is currently opened in another window
@@ -382,30 +386,34 @@ export class WorkspaceEditingService implements IWorkspaceEditingService {
382386 }
383387
384388 const workspace = await this . workspaceService . getWorkspaceIdentifier ( path ) ;
389+
385390 // Settings migration (only if we come from a folder workspace)
386391 if ( this . contextService . getWorkbenchState ( ) === WorkbenchState . FOLDER ) {
387392 await this . migrateWorkspaceSettings ( workspace ) ;
388393 }
394+
389395 const workspaceImpl = this . contextService as WorkspaceService ;
390396 await workspaceImpl . initialize ( workspace ) ;
391397
392- // Restart extension host if first root folder changed (impact on deprecated workspace.rootPath API)
393- // Stop the extension host first to give extensions most time to shutdown
394- this . extensionService . stopExtensionHost ( ) ;
395-
396398 const result = await this . windowService . enterWorkspace ( path ) ;
397399 if ( result ) {
398400 await this . migrateStorage ( result . workspace ) ;
401+
399402 // Reinitialize backup service
400403 if ( this . backupFileService instanceof BackupFileService ) {
401404 this . backupFileService . initialize ( toBackupWorkspaceResource ( result . backupPath ! , this . environmentService ) ) ;
402405 }
403406 }
404407
408+ // TODO@aeschli : workaround until restarting works
405409 if ( this . environmentService . configuration . remoteAuthority ) {
406- this . windowService . reloadWindow ( ) ; // TODO aeschli: workaround until restarting works
407- } else {
408- this . extensionService . startExtensionHost ( ) ;
410+ this . windowService . reloadWindow ( ) ;
411+ }
412+
413+ // Restart the extension host: entering a workspace means a new location for
414+ // storage and potentially a change in the workspace.rootPath property.
415+ else {
416+ this . extensionService . restartExtensionHost ( ) ;
409417 }
410418 }
411419
0 commit comments