How to change workspace in plugin

I want to create a new folder with a git repo.
I clone the repo, and then I want theia workspace change to this folder.
how can I do this? what api I can use

@yuzai from a vscode extension you can use the builtin command to open a folder:

thank you first.
but I use theia-plugin already, do I have api in theia plugin?

@yuzai if you must use a theia-plugin you can simply execute existing registered commands which are at your disposal:

Any contributed command are available to any plugin, command can be invoked by executeCommand function.

I do not believe there is there is an existing command at the moment provided by the framework to open a folder directly, only a command to trigger the selection of a folder through the file-dialog:

As you can see, the plugin system implements the vscode command specifically so it can open a passed URI as a workspace. You can probably attempt to do the same thing, or through your plugin implement the feature to open a workspace using existing commands:

thanks very much.
I execute the theia.window.getCommands, and then I found that vscode.openFolder command is in there.
so I just use this command in theia plugin, it worked.
theia.commands.executeCommand('vscode.openFolder', uri) .
thank you again.

1 Like