Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

delay hosted plugins' initialization #4383

Merged
merged 2 commits into from
Feb 21, 2019

Conversation

elaihau
Copy link
Contributor

@elaihau elaihau commented Feb 19, 2019

setup plugin api before plugins are started

  • in current Theia code plugins are loaded and activated before the plugin api becomes ready. This change fixes this problem.

Signed-off-by: elaihau [email protected]

delay hosted plugins' initialization

  • When plugins query the workspace.workspaceFolders, Theia plugin api returns undefined when there is no workspace open, or the opened workspace has not been resolved by WorkspaceService. And this is inconsistent with vsCode, where the extension host is not started until the initialize function of WorkspaceService returns. This change delays the initialization and loading of plugins to ensure workspace root(s) are resolved beforehand.

Signed-off-by: elaihau [email protected]

elaihau added 2 commits February 19, 2019 17:51
- When plugins query the `workspace.workspaceFolders`, Theia plugin api returns `undefined` when there is no workspace open, or the opened workspace has not been resolved by `WorkspaceService`. And this is inconsistent with vsCode, where the extension host is not started until the `initialize` function of `WorkspaceService` returns. This change delays the initialization and loading of plugins to ensure workspace root(s) are resolved beforehand.

Signed-off-by: elaihau <[email protected]>
- in current Theia code plugins are loaded and activated before the plugin api becomes ready. This change fixes this problem.

Signed-off-by: elaihau <[email protected]>
@elaihau
Copy link
Contributor Author

elaihau commented Feb 19, 2019

in vscode the extension host is started like this:

	enterWorkspace(path: URI): Promise<void> {

		// Stop the extension host first to give extensions most time to shutdown
		this.extensionService.stopExtensionHost();
		let extensionHostStarted: boolean = false;

		const 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(() => {
                                        // ... ...
                                        // ... ...
					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);
		});

https://github.com/Microsoft/vscode/blob/434407d3d530646cc8a6d57ec8d662465c20f19d/src/vs/workbench/services/workspace/node/workspaceEditingService.ts#L251

Therefore, workspace.workspaceFolders never returns a undefined if the vscode instance is started with an opened workspace / folder

Copy link
Contributor

@benoitf benoitf left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thx @elaihau

@elaihau elaihau merged commit fcb4001 into eclipse-theia:master Feb 21, 2019
@elaihau elaihau deleted the delay-plugin-host branch February 21, 2019 13:47
@elaihau
Copy link
Contributor Author

elaihau commented Mar 1, 2019

related to #4216

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants