diff --git a/src/vs/workbench/contrib/tasks/browser/terminalTaskSystem.ts b/src/vs/workbench/contrib/tasks/browser/terminalTaskSystem.ts index 969c0f9c1ea60babff9eeb8c0b54399a9398a7a6..9137ba2d1b3c97147f3756b505f1ee3127c6e34c 100644 --- a/src/vs/workbench/contrib/tasks/browser/terminalTaskSystem.ts +++ b/src/vs/workbench/contrib/tasks/browser/terminalTaskSystem.ts @@ -368,11 +368,7 @@ export class TerminalTaskSystem implements ITaskSystem { }); } - private removeFromActiveTasks(task: Task): void { - if (!this.activeTasks[task.getMapKey()]) { - return; - } - delete this.activeTasks[task.getMapKey()]; + private removeInstances(task: Task) { let commonKey = task._id.split('|')[0]; if (this.instances[commonKey]) { this.instances[commonKey].removeInstance(); @@ -382,6 +378,14 @@ export class TerminalTaskSystem implements ITaskSystem { } } + private removeFromActiveTasks(task: Task): void { + if (!this.activeTasks[task.getMapKey()]) { + return; + } + delete this.activeTasks[task.getMapKey()]; + this.removeInstances(task); + } + public terminate(task: Task): Promise { let activeTerminal = this.activeTasks[task.getMapKey()]; if (!activeTerminal) { @@ -466,6 +470,7 @@ export class TerminalTaskSystem implements ITaskSystem { return Promise.all(promises).then((summaries): Promise | ITaskSummary => { for (let summary of summaries) { if (summary.exitCode !== 0) { + this.removeInstances(task); return { exitCode: summary.exitCode }; } }