Skip to content

Commit

Permalink
edit the right task.json when clicking "configure task" in multi-root…
Browse files Browse the repository at this point in the history
… workspace

- fixed #4919

Signed-off-by: Liang Huang <liang.huang@ericsson.com>
  • Loading branch information
Liang Huang committed Jul 20, 2019
1 parent 3587c23 commit fe431f2
Showing 1 changed file with 17 additions and 2 deletions.
19 changes: 17 additions & 2 deletions packages/task/src/browser/task-configurations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,19 @@ export class TaskConfigurations implements Disposable {
return;
}

const configFileUri = this.getConfigFileUri(workspace.uri);
const isDetectedTask = this.isDetectedTask(task);
let sourceFolderUri: string | undefined;
if (isDetectedTask) {
sourceFolderUri = task._scope;
} else {
sourceFolderUri = task._source;
}
if (!sourceFolderUri) {
console.error('Global task cannot be customized');
return;
}

const configFileUri = this.getConfigFileUri(sourceFolderUri);
if (!this.getTasks().some(t => t.label === task.label)) {
await this.saveTask(configFileUri, task);
}
Expand Down Expand Up @@ -330,7 +342,10 @@ export class TaskConfigurations implements Disposable {

/** checks if the config is a detected / contributed task */
private isDetectedTask(task: TaskConfiguration): task is ContributedTaskConfiguration {
const taskDefinition = this.taskDefinitionRegistry.getDefinition(task);
const taskDefinition = this.taskDefinitionRegistry.getDefinition({
...task,
type: task.taskType || task.type
});
// it is considered as a customization if the task definition registry finds a def for the task configuration
return !!taskDefinition;
}
Expand Down

0 comments on commit fe431f2

Please sign in to comment.