DEV Community

VS Code Profile Switcher Extensions Support

Aaron Powell on July 25, 2019

I've just released some updates to my VS Code Profile Switcher extension which adds the feature that was most required when I first announced it, e...
Collapse
 
jefrypozo profile image
Jefry Pozo

It is a good idea. How did I never thought of it?

Jokes aside, I'm curious. Why do you remove the extensions instead of disabling them?
Doesn't disabling them accomplish the goal of getting down the memory footprint and/or load times?

Collapse
 
aaronpowell profile image
Aaron Powell

It would, but unfortunately there's no API that's exposed to extensions that allows you to disable an extension.

I did some digging around the VS Code source and it looks like disabling extensions requires writing to one of the databases that VS Code uses internally, not just setting some config flags or anything.

Because of that I decided I wouldn't try and disable (don't want to risk corrupting the database) the extensions, just remove them.

Collapse
 
aaronpowell profile image
Aaron Powell

Interesting aside - when you disable an extension in VS Code it isn't returns in the list of extensions that the extensions API has access to.

Collapse
 
jefrypozo profile image
Jefry Pozo

I see. Microsoft is known for making extensions development complicated sometimes.

Anyway, it is a good extension. Keep the good work. 👍

Thread Thread
 
aaronpowell profile image
Aaron Powell

It's a fine balance between performance, extensibility and reliability.

I do agree that you don't want to have extensions that can easily interfere with the operation of other extensions, if it was easy to disable extensions then you could end up with a malicious extension author messing with what's loaded.

Similarly, the more of the internals available to an extension the more you risk startup penalties because you have to make a larger sandbox.

Browsers suffer a similar problem, the more they allow you to do in an extension the more it risks the performance of the browser, and it's more often than not the browser that the finger gets pointed at than the extension.

Thread Thread
 
jefrypozo profile image
Jefry Pozo

I agree with you on those points. I haven't really looked into VSCode extensibility, but I had a sour experience with Visual Studio when developing an extension for changing text editor colors.

But nonetheless, I think the ability to disable extensions has a lesser impact than removing extensions if security is the concern. Said in another way, I believe being able to remove them is worst than being able to disable them.

Collapse
 
equiman profile image
Camilo Martinez

I'm waiting for something like that for months.

Thank's ... I will test it.

Collapse
 
aaronpowell profile image
Aaron Powell

Let me know how it goes for you and if there's anything you want from it 😁

Collapse
 
equiman profile image
Camilo Martinez

Could you explain better how SyncExtension deal with this?

Upload the current profile? Or upload all profiles?

Thread Thread
 
aaronpowell profile image
Aaron Powell

Are you referring to Settings Sync?

Settings Sync works by taking a copy of your settings.json and uploading it to a gist, along with the metadata of your currently active extensions (and a few other pieces).

Since my extension also uses the settings.json file to store everything they'll get uploaded with Settings Sync. I actually use that myself to sync between VS Code and VS Code Insiders (easiest way to have 2 independent installs!).

Thread Thread
 
equiman profile image
Camilo Martinez

OK, perfect. This weekend I'll create my profiles: Vanilla JS/Angular/.Net. :D

Thanks!

Thread Thread
 
equiman profile image
Camilo Martinez • Edited

I already tested your extension, thanks for your work it's amazing. It's a good way to deal with extensions on vscode.

I have some comments about, after tested.

  1. I think "profileSwitcher.storage" it's unnecessary because vscode have 2 files for configuration.
    User configuration for general purpose and project settings (.vscode/settings.json) for specific configurations. Then you can setup those changes on this files.
    I understand some user can found it useful and I'll recommend add a property to disable with a property.

  2. I have a problem when work with two kind of projects (C# and Web), because when switch between profiles are installing and uninstalling extensions but this apply to all vscode session. That's how works vscode currently and it's not the extension fault, you can use it, but can't work on different kind of projects.
    Instead of install and uninstall I think a solution can be save on each profile a list of extensions to disable. When switch to this profiles, disable those extension on current project. But i have no idea how difficult is do that.
    Until that a workaround could be work one session on vscode and other on insiders version.

  3. ¿It's there a way to add a property on project setting (.vscode/settings.json) to select automatically a Profile?

Thanks again. Amazing job!
Let me know if can help testing something.

Thread Thread
 
aaronpowell profile image
Aaron Powell

Thanks for the feedback Camilo, I'll answer in reverse order (and they are easier to answer that way!).

3. Currently no, the only "auto-select" for a profile is when you go into Live Share. That said, it's something I was thinking about last week and may add if there's demand (would just need to work out how best to do it).

2. Alas there's no way for me to disable extensions, it's uninstall or nothing, see this comment: dev.to/aaronpowell/comment/dd3a

1. I made a deliberate decision to not use the .vscode/settings.json file as the place I update for a few reasons. The main reason is that I don't want to do anything that runs the risk of corrupting the current git repo. If the extension updated a file tracked in git then it's a (potential) commit you have to make and a diff that needs to be explained. I'd prefer to not do anything that run the risk of modifying a file that everyone on the team relies on.

Another reason is that I originally wrote this extension for when I give talks. I have to remember to switch my settings to make it optimised for viewing on a projector, and I want those settings across all instances I have open (I may use several demos in a talk). So yes, it was partially built around a workflow I needed.

Lastly, you can already do workspace-specific settings by just using the .vscode/settings.json to what you need (I use to do that for repos explicitly used for presenting), so I didn't want to replicate functionality that already exists.

Hope that explains my thought process/reasoning behind some decisions. 😊

Collapse
 
jsjoeio profile image
Joe Previte (he/him)

Nice work, Aaron! :D Thanks again for making this. I've started using it to help me learn vim.

i.e. I have one profile for vim and another for my regular setup. Makes it really easy to switch back and forth!