Skip to content
This repository has been archived by the owner on Jul 18, 2022. It is now read-only.

[Question] Loading extensions by profile #2

Closed
thienlhh opened this issue Jun 30, 2019 · 6 comments
Closed

[Question] Loading extensions by profile #2

thienlhh opened this issue Jun 30, 2019 · 6 comments
Assignees

Comments

@thienlhh
Copy link

Can we adjust which extension to be loaded per profile along with other settings?

@aaronpowell aaronpowell self-assigned this Jun 30, 2019
@aaronpowell
Copy link
Owner

aaronpowell commented Jun 30, 2019

It's a really good question, I'm going to investigate it (as I'd like that feature too, but settings was top priority).

One thing that may be a challenge with extensions is that some could require a reload of VSCode if you enable/disable it. Would it be acceptable to have that happen?

Also, I'd look to just programmatically disable the extensions rather than install/uninstall, as that should speed things up. Again, would that be an acceptable user experience?

@aaronpowell
Copy link
Owner

I've spent a bit of time digging into this today, it looks like it's a bit trickier than I was hoping for.

It looks like it might not be possible to programmatically enable/disable extensions, and there's also not an API that I can lean on. I'd have to employ an approach similar the way Settings Sync works.

I'll have a look at that tomorrow.

@mburleigh
Copy link

Would it be possible to swap out the extensions directory and/or the user data directory at runtime? I've set up different VS Code shortcuts in the past to launch Code with different sets of extensions for different workloads using '--extensions-dir' & '--user-data-dir' on the command line and it works great. (gotta believe that would require a reload though)

@aaronpowell
Copy link
Owner

@mburleigh I'll do some investigation into the source, but I highly doubt that at run time I can interact with Code at such a low level. I know there's a bunch of APIs that would be useful for me to access but they don't get exposed to the extension host (as far as I can tell at least).

@aaronpowell
Copy link
Owner

aaronpowell commented Jul 2, 2019

I've made some progress on this today, and it's in this commit: dc1d39b

It's not complete, so I won't release it (if you want to test it you can grab it off the build job).

The way it works is:

  • When you save your profile it'll take all the currently loaded extensions and mark them as part of the profile
  • When you load a profile it'll grab that list of extensions, remove the ones that aren't in it and add the ones that are there
    • The remove works by backing them up to a folder on disk and then deleting them. This means that when switch to a profile that needs it it can grab it locally rather than downloading
    • The install doesn't work properly yet, if you have it in the backup, it'll be fine, otherwise it should install it from the marketplace (but that's tomorrows job)

I'd love someone to test it for me if you're brave enough! You can side-load the extension with https://code.visualstudio.com/api/working-with-extensions/publishing-extension#packaging-extensions

Edit: Ok, looks like the artifact isn't publicly accessible, so if you want to test it for me you can clone the repo and run the extension.

aaronpowell added a commit that referenced this issue Jul 2, 2019
Should mostly switch fine
Backs up extensions to globalStorage when you remove them for faster reload
Install not working yet
@aaronpowell
Copy link
Owner

# for free to subscribe to this conversation on GitHub. Already have an account? #.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants