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

After running "workbench.extensions.installExtension", extensions.getExtension still returns undefined #71943

Closed
DanTup opened this issue Apr 8, 2019 · 2 comments
Assignees
Labels
extensions Issues concerning extensions info-needed Issue requires more information from poster

Comments

@DanTup
Copy link
Contributor

DanTup commented Apr 8, 2019

After installing an extension with workbench.extensions.installExtension it seems impossible to activate the extension because vs.extensions.getExtension returns undefined.

For ex:

if (res === installExtension) {
		await vs.commands.executeCommand("workbench.extensions.installExtension", flutterExtensionIdentifier);
		console.warn('...');
		console.warn(vs.extensions.getExtension(flutterExtensionIdentifier));
	}

prints:

...
undefined
@sandy081
Copy link
Member

sandy081 commented Apr 9, 2019

@DanTup I do not think vs.extensions gets populated immediately, you have to listen to the changes on vscode.extensions.

@sandy081 sandy081 added the info-needed Issue requires more information from poster label Apr 9, 2019
@DanTup
Copy link
Contributor Author

DanTup commented Apr 9, 2019

@sandy081 Aha! I thought the command would wait for it to complete, but you're right - this seems to do the trick. Thanks!

await vs.window.withProgress({ location: vs.ProgressLocation.Notification },
	(progress) => {
		progress.report({ message: "Installing Flutter extension" });

		return new Promise((resolve) => {
			vs.extensions.onDidChange((e) => resolve());
			vs.commands.executeCommand("workbench.extensions.installExtension", flutterExtensionIdentifier);
		});
	},
);

@DanTup DanTup closed this as completed Apr 9, 2019
@vscodebot vscodebot bot locked and limited conversation to collaborators May 24, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
extensions Issues concerning extensions info-needed Issue requires more information from poster
Projects
None yet
Development

No branches or pull requests

2 participants