提交 4600555b 编写于 作者: S Sandeep Somavarapu

change the order while entering workspace:

initialise, stop and start
上级 4eb2344d
...@@ -284,10 +284,10 @@ export class WorkspaceService extends Disposable implements IConfigurationServic ...@@ -284,10 +284,10 @@ export class WorkspaceService extends Disposable implements IConfigurationServic
return this._configuration.keys(); return this._configuration.keys();
} }
initialize(arg: IWorkspaceInitializationPayload, postInitialisationTask: () => void = () => null): Promise<any> { initialize(arg: IWorkspaceInitializationPayload): Promise<any> {
mark('willInitWorkspaceService'); mark('willInitWorkspaceService');
return this.createWorkspace(arg) return this.createWorkspace(arg)
.then(workspace => this.updateWorkspaceAndInitializeConfiguration(workspace, postInitialisationTask)).then(() => { .then(workspace => this.updateWorkspaceAndInitializeConfiguration(workspace)).then(() => {
mark('didInitWorkspaceService'); mark('didInitWorkspaceService');
}); });
} }
...@@ -382,7 +382,7 @@ export class WorkspaceService extends Disposable implements IConfigurationServic ...@@ -382,7 +382,7 @@ export class WorkspaceService extends Disposable implements IConfigurationServic
} }
} }
private updateWorkspaceAndInitializeConfiguration(workspace: Workspace, postInitialisationTask: () => void): Promise<void> { private updateWorkspaceAndInitializeConfiguration(workspace: Workspace): Promise<void> {
const hasWorkspaceBefore = !!this.workspace; const hasWorkspaceBefore = !!this.workspace;
let previousState: WorkbenchState; let previousState: WorkbenchState;
let previousWorkspacePath: string | undefined; let previousWorkspacePath: string | undefined;
...@@ -399,8 +399,6 @@ export class WorkspaceService extends Disposable implements IConfigurationServic ...@@ -399,8 +399,6 @@ export class WorkspaceService extends Disposable implements IConfigurationServic
return this.initializeConfiguration().then(() => { return this.initializeConfiguration().then(() => {
postInitialisationTask(); // Post initialisation task should be run before triggering events.
// Trigger changes after configuration initialization so that configuration is up to date. // Trigger changes after configuration initialization so that configuration is up to date.
if (hasWorkspaceBefore) { if (hasWorkspaceBefore) {
const newState = this.getWorkbenchState(); const newState = this.getWorkbenchState();
......
...@@ -334,64 +334,37 @@ export class WorkspaceEditingService implements IWorkspaceEditingService { ...@@ -334,64 +334,37 @@ export class WorkspaceEditingService implements IWorkspaceEditingService {
); );
} }
enterWorkspace(path: URI): Promise<void> { async enterWorkspace(path: URI): Promise<void> {
if (!!this.environmentService.extensionTestsLocationURI) { if (!!this.environmentService.extensionTestsLocationURI) {
return Promise.reject(new Error('Entering a new workspace is not possible in tests.')); return Promise.reject(new Error('Entering a new workspace is not possible in tests.'));
} }
const workspace = await this.workspaceService.getWorkspaceIdentifier(path);
// Settings migration (only if we come from a folder workspace)
if (this.contextService.getWorkbenchState() === WorkbenchState.FOLDER) {
await this.migrateWorkspaceSettings(workspace);
}
const workspaceImpl = this.contextService as WorkspaceService;
await workspaceImpl.initialize(workspace);
// Restart extension host if first root folder changed (impact on deprecated workspace.rootPath API) // Restart extension host if first root folder changed (impact on deprecated workspace.rootPath API)
// Stop the extension host first to give extensions most time to shutdown // Stop the extension host first to give extensions most time to shutdown
this.extensionService.stopExtensionHost(); this.extensionService.stopExtensionHost();
let extensionHostStarted: boolean = false;
const startExtensionHost = () => { const result = await this.windowService.enterWorkspace(path);
if (this.windowService.getConfiguration().remoteAuthority) { if (result) {
this.windowService.reloadWindow(); // TODO aeschli: workaround until restarting works await this.migrateStorage(result.workspace);
// Reinitialize backup service
if (this.backupFileService instanceof BackupFileService) {
this.backupFileService.initialize(result.backupPath!);
} }
}
if (this.windowService.getConfiguration().remoteAuthority) {
this.windowService.reloadWindow(); // TODO aeschli: workaround until restarting works
} else {
this.extensionService.startExtensionHost(); this.extensionService.startExtensionHost();
extensionHostStarted = true; }
};
return this.windowService.enterWorkspace(path).then(result => {
// Migrate storage and settings if we are to enter a workspace
if (result) {
return this.migrate(result.workspace).then(() => {
// Reinitialize backup service
if (this.backupFileService instanceof BackupFileService) {
this.backupFileService.initialize(result.backupPath!);
}
// Reinitialize configuration service
const workspaceImpl = this.contextService as WorkspaceService;
return workspaceImpl.initialize(result.workspace, startExtensionHost);
});
}
return Promise.resolve();
}).then(undefined, error => {
if (!extensionHostStarted) {
startExtensionHost(); // start the extension host if not started
}
return Promise.reject(error);
});
}
private migrate(toWorkspace: IWorkspaceIdentifier): Promise<void> {
// Storage migration
return this.migrateStorage(toWorkspace).then(() => {
// Settings migration (only if we come from a folder workspace)
if (this.contextService.getWorkbenchState() === WorkbenchState.FOLDER) {
return this.migrateWorkspaceSettings(toWorkspace);
}
return undefined;
});
} }
private migrateStorage(toWorkspace: IWorkspaceIdentifier): Promise<void> { private migrateStorage(toWorkspace: IWorkspaceIdentifier): Promise<void> {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册