Skip to content

Commit

Permalink
rm from liveDependenceis/encounteredTasks
Browse files Browse the repository at this point in the history
  • Loading branch information
meganrogge committed May 2, 2023
1 parent 73ea851 commit 4cfa4f8
Show file tree
Hide file tree
Showing 5 changed files with 225 additions and 11 deletions.
7 changes: 7 additions & 0 deletions src/vs/workbench/contrib/tasks/browser/abstractTaskService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -326,6 +326,13 @@ export abstract class AbstractTaskService extends Disposable implements ITaskSer
});
this._lifecycleService.onBeforeShutdown(e => {
this._willRestart = e.reason !== ShutdownReason.RELOAD;
this.getActiveTasks().then(async (tasks) => {
for (const task of tasks) {
if (!task.configurationProperties.isBackground) {
await this.terminate(task);
}
}
});
});
this._register(this.onDidStateChange(e => {
if ((this._willRestart || e.exitReason === TerminalExitReason.User) && e.taskId) {
Expand Down
25 changes: 14 additions & 11 deletions src/vs/workbench/contrib/tasks/browser/terminalTaskSystem.ts
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,7 @@ export class TerminalTaskSystem extends Disposable implements ITaskSystem {
}
const lastTaskInstance = this.getLastInstance(task);
const terminalData = lastTaskInstance ? this._activeTasks[lastTaskInstance.getMapKey()] : undefined;
if (terminalData && terminalData.promise && !validInstance) {
if (terminalData && terminalData.promise && !validInstance && !task.configurationProperties.dependsOn?.length) {
this._lastTask = this._currentTask;
return { kind: TaskExecuteKind.Active, task: terminalData.task, active: { same: true, background: task.configurationProperties.isBackground! }, promise: terminalData.promise };
}
Expand Down Expand Up @@ -540,26 +540,26 @@ export class TerminalTaskSystem extends Disposable implements ITaskSystem {
const dependencyTask = await resolver.resolve(dependency.uri, dependency.task!);
if (dependencyTask) {
this._adoptConfigurationForDependencyTask(dependencyTask, task);
let promise;
let taskResult;
const commonKey = dependencyTask.getCommonTaskId();
if (liveDependencies.has(commonKey)) {
this._showDependencyCycleMessage(dependencyTask);
promise = Promise.resolve<ITaskSummary>({});
taskResult = Promise.resolve<ITaskSummary>({});
} else {
promise = encounteredTasks.get(commonKey);
if (!promise) {
taskResult = encounteredTasks.get(commonKey);
if (!taskResult) {
const key = dependencyTask.getMapKey();
promise = this._activeTasks[key] ? this._getDependencyPromise(this._activeTasks[key]) : undefined;
taskResult = this._activeTasks[key] ? this._getDependencyPromise(this._activeTasks[key]) : undefined;
}
}
if (!promise) {
if (!taskResult) {
this._fireTaskEvent(TaskEvent.create(TaskEventKind.DependsOnStarted, task));
promise = this._executeDependencyTask(dependencyTask, resolver, trigger, liveDependencies, encounteredTasks, alreadyResolved);
taskResult = this._executeDependencyTask(dependencyTask, resolver, trigger, liveDependencies, encounteredTasks, alreadyResolved);
}
encounteredTasks.set(commonKey, promise);
promises.push(promise);
encounteredTasks.set(commonKey, taskResult);
promises.push(taskResult);
if (task.configurationProperties.dependsOrder === DependsOrder.sequence) {
const promiseResult = await promise;
const promiseResult = await taskResult;
if (promiseResult.exitCode !== 0) {
break;
}
Expand Down Expand Up @@ -600,6 +600,9 @@ export class TerminalTaskSystem extends Disposable implements ITaskSystem {
});
}
}).finally(() => {
const commonKey = task.getCommonTaskId();
liveDependencies.delete(commonKey);
encounteredTasks.delete(commonKey);
if (this._activeTasks[mapKey] === activeTask) {
delete this._activeTasks[mapKey];
}
Expand Down
68 changes: 68 additions & 0 deletions test/.vscode/tasks.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
{
"version": "2.0.0",
"tasks": [
{
"type": "shell",
"command": "sleep 2",
"label": "sleeper",
"problemMatcher": [],
"presentation": {
"reveal": "always",
"group": "sleepers",
"close": false
}
},
{
"type": "shell",
"command": "echo task1",
"dependsOn": ["sleeper"],
"label": "task1",
"problemMatcher": [],
"presentation": {
"reveal": "always",
"group": "sleepers",
"close": false
}
},
{
"type": "shell",
"command": "echo task2",
"dependsOn": ["task1"],
"label": "task2",
"problemMatcher": [],
"presentation": {
"reveal": "always",
"group": "sleepers",
"close": false
}
},
{
"type": "shell",
"command": "echo task3",
"dependsOn": ["task1"],
"label": "task3",
"problemMatcher": [],
"presentation": {
"reveal": "always",
"group": "sleepers",
"close": false
}
},
{
"type": "shell",
"command": "echo task4... && sleep 3 && echo ...done",
"dependsOn": ["task2", "task3"],
"label": "task4",
"problemMatcher": [],
"presentation": {
"reveal": "always",
"group": "sleepers",
"close": false
},
"group": {
"kind": "build",
"isDefault": true
}
}
]
}
68 changes: 68 additions & 0 deletions test/test/.vscode/tasks.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
{
"version": "2.0.0",
"tasks": [
{
"type": "shell",
"command": "sleep 2",
"label": "sleeper",
"problemMatcher": [],
"presentation": {
"reveal": "always",
"group": "sleepers",
"close": false
}
},
{
"type": "shell",
"command": "echo task1",
"dependsOn": ["sleeper"],
"label": "task1",
"problemMatcher": [],
"presentation": {
"reveal": "always",
"group": "sleepers",
"close": false
}
},
{
"type": "shell",
"command": "echo task2",
"dependsOn": ["task1"],
"label": "task2",
"problemMatcher": [],
"presentation": {
"reveal": "always",
"group": "sleepers",
"close": false
}
},
{
"type": "shell",
"command": "echo task3",
"dependsOn": ["task1"],
"label": "task3",
"problemMatcher": [],
"presentation": {
"reveal": "always",
"group": "sleepers",
"close": false
}
},
{
"type": "shell",
"command": "echo task4... && sleep 3 && echo ...done",
"dependsOn": ["task2", "task3"],
"label": "task4",
"problemMatcher": [],
"presentation": {
"reveal": "always",
"group": "sleepers",
"close": false
},
"group": {
"kind": "build",
"isDefault": true
}
}
]
}
68 changes: 68 additions & 0 deletions test/test/test/.vscode/tasks.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
{
"version": "2.0.0",
"tasks": [
{
"type": "shell",
"command": "sleep 2",
"label": "sleeper",
"problemMatcher": [],
"presentation": {
"reveal": "always",
"group": "sleepers",
"close": false
}
},
{
"type": "shell",
"command": "echo task1",
"dependsOn": ["sleeper"],
"label": "task1",
"problemMatcher": [],
"presentation": {
"reveal": "always",
"group": "sleepers",
"close": false
}
},
{
"type": "shell",
"command": "echo task2",
"dependsOn": ["task1"],
"label": "task2",
"problemMatcher": [],
"presentation": {
"reveal": "always",
"group": "sleepers",
"close": false
}
},
{
"type": "shell",
"command": "echo task3",
"dependsOn": ["task1"],
"label": "task3",
"problemMatcher": [],
"presentation": {
"reveal": "always",
"group": "sleepers",
"close": false
}
},
{
"type": "shell",
"command": "echo task4... && sleep 3 && echo ...done",
"dependsOn": ["task2", "task3"],
"label": "task4",
"problemMatcher": [],
"presentation": {
"reveal": "always",
"group": "sleepers",
"close": false
},
"group": {
"kind": "build",
"isDefault": true
}
}
]
}

0 comments on commit 4cfa4f8

Please sign in to comment.