Skip to content

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

Closed

Description

@DanTup

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

Activity

  1. sandy081 commented on Apr 9, 2019

    @sandy081
    Member

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

  2. DanTup commented on Apr 9, 2019

    @DanTup
    ContributorAuthor

    Sandeep Somavarapu (@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);
    		});
    	},
    );
  3. locked and limited conversation to collaborators on May 24, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

extensionsIssues concerning extensionsinfo-neededIssue requires more information from poster

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions