Skip to content
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

Change activation event to workspaceContainers #388

Closed
SethFalco opened this issue Dec 12, 2022 · 4 comments · Fixed by #393
Closed

Change activation event to workspaceContainers #388

SethFalco opened this issue Dec 12, 2022 · 4 comments · Fixed by #393

Comments

@SethFalco
Copy link
Contributor

SethFalco commented Dec 12, 2022

Describe the bug

Currently, the extension is set to activate on startup.

image

I'm looking through the activation events of all my extensions since lately, I've noticed some of them activate eagerly even when they don't apply to my workspace, which makes the startup slower and uses more resources on my system. This adds up when you have many extensions, i.e. I have 92.

VSC provides an activation event for when a certain file pattern is matched in the workspace:

https://code.visualstudio.com/api/references/activation-events#workspaceContains

Do you think it would be feasible to move the activation event for this extension from * to workspaceContains?

For example:

{
  "activationEvents": [
    "workspaceContains:**/*.xml",
    "workspaceContains:**/lcov.info"
  ]
}

Activate if the workspace contains an XML file, or lcov.info.

Desktop (please complete the following information):

  • OS: linux
  • Extension Version v2.10.2
  • VSCode Version:
Version: 1.75.0-insider
Commit: f076d553210e9ea65e7bccbfa2f7a786c10fcab2
Date: 2022-12-09T09:09:03.185Z
Electron: 19.1.8
Chromium: 102.0.5005.167
Node.js: 16.14.2
V8: 10.2.154.15-electron.0
OS: Linux x64 6.0.0-5-amd64 snap
Sandboxed: Yes

Additional context

Note, if workspaceContains might not be appropriate, we could still consider moving it from * to onStartupFinished.

This activation event is emitted and interested extensions will be activated some time after VS Code starts up. This is similar to the * activation event, but it will not slow down VS Code startup. Currently, this event is emitted after all the * activated extensions have finished activating.

https://code.visualstudio.com/api/references/activation-events#onStartupFinished

For example:

{
  "activationEvents": [
    "onStartupFinished"
  ]
}
@ryanluker
Copy link
Owner

ryanluker commented Feb 13, 2023

@SethFalco Thanks for the ticket!

Definitely would be better to turf the on startup instantiation of this extension (this was the only option when I initially developed it, I think...).

I like both ideas, but I think it is reasonable to only load the extension if an applicable file is found. I do wonder about how we might consider other file types not defined in the default list.

https://github.com/ryanluker/vscode-coverage-gutters/blob/master/package.json#L129-L135

@SethFalco
Copy link
Contributor Author

SethFalco commented Feb 14, 2023

I do wonder about how we might consider other file types

Unfortunately, I don't think VSC has a way to change activation based on settings, so if you're expecting users to specify additional files that are not info.lcov or **/*.xml, then the only option would be onStartupFinished I think. 🤔

Some other extensions have a similar issue, for example SonarSource/sonarlint-vscode, prettier/prettier-vscode, and microsoft/vscode-eslint could just specify to only activate on the list of officially supported languages, but users can also have plugins/projects/settings that define or target other languages, so even if it's not too often, they need to use onStartupFinished instead.

Fine with using onStartupFinished at least, though?

@ryanluker
Copy link
Owner

ryanluker commented Feb 16, 2023

@SethFalco Agreed that onStartupFinished sounds like a good first step!
Thanks for the links to over extensions as well, it looks to be the norm to use this event instead which is nice to keep inline with the community 👍🏻.

@ryanluker ryanluker added this to the 2.11.0 milestone Feb 16, 2023
@ryanluker
Copy link
Owner

@SethFalco Thanks again for the contribution and the PR, the change should go out in 2.11.0

@ryanluker ryanluker modified the milestones: 2.11.0, 2.10.4 Mar 19, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants