From 08929a298f39fee7eb936bfef30b57621f16d256 Mon Sep 17 00:00:00 2001 From: meganrogge Date: Tue, 2 May 2023 05:38:12 -0700 Subject: [PATCH] rm from liveDependencies/encounteredTasks --- .../tasks/browser/abstractTaskService.ts | 7 ++ .../tasks/browser/terminalTaskSystem.ts | 25 ++++--- test/.vscode/tasks.json | 68 +++++++++++++++++++ test/test/.vscode/tasks.json | 68 +++++++++++++++++++ test/test/test/.vscode/tasks.json | 68 +++++++++++++++++++ 5 files changed, 225 insertions(+), 11 deletions(-) create mode 100644 test/.vscode/tasks.json create mode 100644 test/test/.vscode/tasks.json create mode 100644 test/test/test/.vscode/tasks.json diff --git a/src/vs/workbench/contrib/tasks/browser/abstractTaskService.ts b/src/vs/workbench/contrib/tasks/browser/abstractTaskService.ts index b0e9ee2cbc069..e670705d52479 100644 --- a/src/vs/workbench/contrib/tasks/browser/abstractTaskService.ts +++ b/src/vs/workbench/contrib/tasks/browser/abstractTaskService.ts @@ -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) { diff --git a/src/vs/workbench/contrib/tasks/browser/terminalTaskSystem.ts b/src/vs/workbench/contrib/tasks/browser/terminalTaskSystem.ts index 5eac75c7c95e9..a8ca158717a69 100644 --- a/src/vs/workbench/contrib/tasks/browser/terminalTaskSystem.ts +++ b/src/vs/workbench/contrib/tasks/browser/terminalTaskSystem.ts @@ -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 }; } @@ -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({}); + taskResult = Promise.resolve({}); } 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; } @@ -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]; } diff --git a/test/.vscode/tasks.json b/test/.vscode/tasks.json new file mode 100644 index 0000000000000..0f58a805dc719 --- /dev/null +++ b/test/.vscode/tasks.json @@ -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 + } + } + ] +} diff --git a/test/test/.vscode/tasks.json b/test/test/.vscode/tasks.json new file mode 100644 index 0000000000000..0f58a805dc719 --- /dev/null +++ b/test/test/.vscode/tasks.json @@ -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 + } + } + ] +} diff --git a/test/test/test/.vscode/tasks.json b/test/test/test/.vscode/tasks.json new file mode 100644 index 0000000000000..0f58a805dc719 --- /dev/null +++ b/test/test/test/.vscode/tasks.json @@ -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 + } + } + ] +}