-
Notifications
You must be signed in to change notification settings - Fork 30.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Do not activate extension with workspaceContains always after installing #75284
Comments
Actually, just installed Dart directly shows the same thing. What's strange is that installing the Flutter one does not activate the Flutter extension, so it's not like it's just activating whatever I install immediately 🤔 |
Hmmm, I think it's because of this: vscode/src/vs/workbench/services/extensions/electron-browser/extensionService.ts Lines 306 to 307 in 022835e
😕 |
FWIW the code above was added in 7304f38 (it's in a different file, as it was moved around a bit). I can't see a PR so not sure whether this was to fix an issue or something (cc @alexandrudima), but it's a bit undesirable for extensions that want to prompt the user to install an SDK based on the type of the open project. Currently we have no way to tell if VS Code activated this extension pre-emptively, or if the activation events were actually matched (so we can't even skip the prompt without re-checking for all the conditions ourselves). |
It was intentional to always activate any extension that has workspace contains activation event after installing due to the performance reasons. I would wait for @alexandrudima 's opinion on this. |
I suspected it was performance related, but I think it's a false economy because:
You're doing that work on a folder open anyway, I don't see why doing it at extension install is a huge deal (you probably already have some of the tree cached in the rendering for the explorer tree at this time too). Also - if it's not considered a bug that extensions can activate when their conditions are not met, I think it should be called out explicitly in the docs (so it's clear they should decide whether or not they really should start up language servers, show user prompts, etc.). |
An extension can be activated outside the That being said, the majority of extensions are not insanely expensive to activate... The entire idea of activation events is to reduce the impact extensions have on startup and to be economical, of course. But imagine the following scenario: the editorconfig extension activates on The editorconfig extension works by looking at the current opened text buffer and going up the folder hierarchy looking for So IMHO it is not such a clear lack of judgement on our side to give up after some time and defer the decision of doing something to the extension. The extension has domain knowledge that we lack, an extension can implement something smarter than we can. The extension can also start searching and realising after a while that it is on a huge folder, but then it can present a popup which is specific to the extension, it can ask the user to define what exact behaviour they want... For us, in the core, the decision is:
I still believe we are doing the best given the limited information we have... The only thing which is debatable is for how long should we search until we give up. I think we just chose a number which seems reasonable... |
Extensions have even more limited info though - we don't even get given the activation reason (I did ask). In fact, I recently opened a Dart project and the C# extension started downloading all sorts of .NET dependencies to my machine. The C# extension activates on tons of events (for ex. onDebugInitialConfigurations) and then just downloads all its dependencies regardless of what you have open. So the faster startup isn't really faster if extensions are doing lots of expensive work themselves.
There is no search. Check the code that I included above: vscode/src/vs/workbench/services/extensions/electron-browser/extensionService.ts Lines 306 to 307 in 022835e
When you install an extension, it just pre-emptively activates it if it has an onWorkspaceContains :( |
I just saw this again. I opened VS Code and it auto-updated the C# extension (I had a Dart project open). Because of this behaviour, the C# extension was unnecessarily activated. It then started downloading dependencies: This logic doesn't seem to hold up. You're avoiding doing expensive things at startup and causing extensions to not only do expensive things, but illogical things. Fast forward a few years where I have 20 extensions that work like the C# one, and I've potentially got 20 extensions downloading SDKs when I opened VS Code with none of their projects open. Is this really working as intended? |
To verify: Have an extension that uses |
…extension with workspaceContains
…extension with workspaceContains
@DanTup If you have a chance, could you please verify this? |
@alexdima sorry for the delay! I tested this in latest insiders, and it works great! With a non-Dart project open, if I install Dart/Flutter extensions, there is no activation. If I repeat with a Dart/Flutter extension open, they activate. Thanks! |
Thank you! ❤️ |
I had a report of strange behaviour when installed the Flutter extension - it prompts you to install a Dart SDK (when you probably want to use Flutter, not Dart). It seems like installing the Flutter extension is activating the Dart extension (it does depend on it) even though no activation requirements for either extension are met, and the reason in the log is incorrect ("workspaceContains:**/pubspec.yaml").
Here's what I did:
Here's a screenshot showing I don't have a folder open with a
pubspec.yaml
in it:Is this expected? Can I stop it?
The text was updated successfully, but these errors were encountered: