-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
Support User Level Tasks #7446
Comments
cc @elaihau : Liang, I think you've been involved in a lot of the development in this area. Coul you assist Thomas with related questions he may have? |
I did a little experiment with a VS Code extensions doing the following: const value= vscode.workspace.getConfiguration('tasks');
vscode.window.showInformationMessage(JSON.stringify(value)); When I add a task to So it seem like tasks are indeed treated differently whether you are accessing them through the configuration API or the tasks UI. |
When I change the code to do vscode.tasks.fetchTasks().then((value)=> {
console.info((JSON.stringify(value));
vscode.window.showInformationMessage(JSON.stringify(value));
}); I see the tasks from the user settings in the output. |
@tsmaeder thank you! It sounds like the change should be applied only to |
Yes, I believe so, but slightly disappointed at VS Code for the inconsistency ;-) |
A couple of experiments I ran:
{
"label": "this is the build",
"type": "npm",
"script": "build",
"path": "examples/browser/"
} As long as I keep "type", "script" and "path" the same, this will always count as a configuration of the "npm: build - examples/browser" detected task. If I change any of them, it's not related anymore. I haven't yet done any experiments with "scope", though. |
Note: the document here seems to indicate that stuff in tasks.json can only ever be a "customization" of a contributed tasks, but that is not the case: you can create tasks of type "npm", for example that are not considered customizations of a contributed task. |
@elaihau I was wondering why we allow multiple TaskDefinition object for the same task type. How would we have to different definitions for the "npm" task type? I |
when i wrote that part of the code i followed the vscode design to achieve the compatibility. Take Since I have never seen any extensions that contribute more than one task definition, to answer your question I can only make guesses :)
You might want to argue that |
@elaihau I understand that the same extension can contribute more than one task definition, but can more than one task definition contribution have the same type field? Because the code in TaskDefinitionRegistry seems to indicate that there can be more than one tasks definition for "typescript", for example. "typescript" as the task type, not the extension. If I write an extension that also contributes a "typescript" task type, I think that would be an error, no? |
You are right @tsmaeder . In Theia, although our API looks compatible with vscode's, we don't actually have code to support having more than one task definitions per extension/plugin, because we don't have anything that stores the associations between extension/plugin and task definition names. It is definitely something we should improve :) |
@elaihau not what I'm talking about: I am talking about more than one definition for the same type "taskDefinitions": [
{
"type": "foo",
"required": [
],
"properties": {
...
}
},
{
"type": "foo",
"required": [
],
"properties": {
...
}
}
] but the one below is correct: "taskDefinitions": [
{
"type": "foo",
"required": [
],
"properties": {
...
}
},
{
"type": "bar",
"required": [
],
"properties": {
...
}
}
] |
ah, got it. we don't throw any errors if multiple task definitions having same names are defined under the same extension/plugin. And we should. |
I don't think VS Code does either, but didn't check real well... |
Well, just added a task definition of type "npm" into my test extension: VS Code indeed just seems to take the last definition it sees: no error is signalled. |
Actually not true: you need to have a contributed tasks, otherwise you can't run the task |
Other fun experiment: Contribute two tasks with the exact same values (origin, name, scope, type, ...) and VS Code will happily treat those two as different tasks. I think contributed tasks have identity. We seem to address tasks through "label", "source", "scope". Not sure that is correct. |
Here's the test extension I'm using. |
Thank you Thomas ! This is really helpful ! |
VS Code now supports defining tasks at the user level: https://code.visualstudio.com/updates/v1_42#_user-level-tasks
Since we're already using PreferenceConfigurations for reading tasks from source folders, it would be logical to extend the same approach to user-level configurations.
The problems here is that our current preference merging algorithm would override the task defined at user level, when the desired behavior (as observed in VS Code) would be to merge the list of user tasks.
The text was updated successfully, but these errors were encountered: