Workspace + Default Project Dir (Visual Studio Code)

Hi,

Setup
Visual Studio Code with
PlatformIO extension (Home 2.3.3, Core 4.0.3)

Question
A) How do I specify the default project directory? This doc does not seem to cover the Visual Studio extension?
http://docs.platformio.org/en/latest/userguide/cmd_settings.html#projects-dir

B) In Visual Studio, how do I make use of Workspaces when using PlatformIO? When I create a new project, it seems like it is not opened in a workspace? I would like to have multiple projects grouped in a workspace. Is that possible with PlatformIO extension?

Thanks.

1 Like

For a), whilst that setting doesn’t cover the VSCode extension, that setting still sets the default project directory as it’s used by PIO Home, which really does the work.

i.e. you can see I’ve changed the default path

and this creatively named newProject is now located (when leaving the ‘Use default localtion’ checkbox ticked when creating the project) in:

image

For B) when you create a new project, it will be added to an existing workspace. If you don’t have one open, it effectively creates one. If you want to add more projects to a workspace, use the ‘File → Add Folder’ option to add the project’s folder to the workspace.

image

A multi-root workspace will have the different folders like so:

image

Thanks for your reply.

How do I open the ‘console’ in order to type the PlatformIO cmds to change project dir?

Either through the sidebar, quick access icons in the status bar, or the Command Palette (Ctrl + Shift+P) and type terminal for PlatformIO: New Terminal

Awesome, thanks! That is now changed to my preferred location :slight_smile:

I have an issue, where the key focus is not correct. It only happens in the PIO Home tab. Eg:

  • I try to create a “New Project”. I click in the Name field, which then show up with a blue border. But I cannot enter anything…
  • I try to search for a library. Same thing, the input box shows with a blue border when I click it with the mouse, but I cannot input data.

Is this something you have experienced? It has happend quite a lot of times now. So far, it seems like the PIO Home tab is working when Visual Code has just been launched. But if I did anything else (e.g. run the commands in the terminal, or edited an existing project) the key focus seems to be lost in PIO Home, and can only be restored by closing Visual Studio and open it again.

Excellent! :slight_smile:

There is a known issue in the VSCode extension API which means that the webview handler used by PlatformIO and a bunch of other extensions loses keyboard/input focus if you click some other element of VSCode. The workaround is to double-click the PIO tab up the top and then it should have keyboard/input focus again.

You can follow this issue on GitHub if you want to find out when it gets fixed.

Thanks for confirming this.

Thanks for all your help. I appreciate it.
PlatformIO seems like a very great IDE, I especially like how libraries are handled.

1 Like

Good info on figuring out how Workspaces apply relative to Projects

Thanks!

1 Like