Fix accidently starting all onTaskType extensions when running any task; fixes #175821#178679
Conversation
|
Does this also fix the issue where launch configs with prelaunchTask will enable everything as well? That one seems to be going through a different code path. |
It should; when testing with following configuration, no additional extensions are activated:
|
|
I tried your above steps and am not seeing the extension get activated when I run an npm task (no status bar item). When I run a command from that extension, I do see it. Screen.Recording.2023-03-30.at.11.57.10.AM.mov |
|
Whoops, I forgot my own repro steps :D. It needs to be a preLaunchTask set to "group": {
"kind": "build",
"isDefault": true
}Even if it doesn't fix that case, this is still a good improvement! (Also, I suppose for clarity: I do not work on VS Code despite the "Member" tag) |
Looked into it and it's not the task that is the problem; it's the variable: when launching, it first tries to resolve all variables present inside the config: When i replace the line above with following code, it works: let resolvedConfig = configByProviders;
resolvedConfig.preLaunchTask = 'run \'npm: test\'';
|
|
Digged depper into this and it seems that the current behaviour regarding vscode/src/vs/workbench/contrib/tasks/browser/abstractTaskService.ts Lines 305 to 306 in b9202b6 When resolving I think it's best to discuss this behaviour and any possible change in this in a new issue. |
|
Yes @Mai-Lapyst you are correct in your understanding and that is why I said in the original issue that the behavior was expected. |
alexr00
left a comment
There was a problem hiding this comment.
I didn't test it out, but the change looks reasonable!

This fixes issue #175821 by only starting extensions of the task's type when trying to reload task after a workspace save.
The original issue falsly is marked as closed, the bug itself isn't resolved; this PR fixes it for good.
To test them:
onTaskTypeactivation event such as rust-lang.rust-analyzer.package.jsonwith following content:{ "scripts": { "test": "echo 'sucessfull runned npm-task'" } }Tasks: Run Task, selectnpm(to discover npm tasks) and runnpm: testrust-analyzeritem in the statusbar which only gets added once the extension is loaded