diff --git a/src/vs/workbench/contrib/tasks/electron-browser/terminalTaskSystem.ts b/src/vs/workbench/contrib/tasks/electron-browser/terminalTaskSystem.ts index 5f53e551e058ab93f8d65d9272db668ccbb8cb8e..5d1612649c830cda9e43d4c08d54c000b2363af5 100644 --- a/src/vs/workbench/contrib/tasks/electron-browser/terminalTaskSystem.ts +++ b/src/vs/workbench/contrib/tasks/electron-browser/terminalTaskSystem.ts @@ -884,7 +884,7 @@ export class TerminalTaskSystem implements ITaskSystem { // (or, if the task has no group, a terminal used by a task without group). for (const taskId of this.idleTaskTerminals.keys()) { const idleTerminalId = this.idleTaskTerminals.get(taskId)!; - if (this.terminals[idleTerminalId].group === group) { + if (idleTerminalId && this.terminals[idleTerminalId].group === group) { terminalId = this.idleTaskTerminals.remove(taskId); break; } @@ -899,6 +899,7 @@ export class TerminalTaskSystem implements ITaskSystem { if (task.command.presentation && task.command.presentation.clear) { terminalToReuse.terminal.clear(); } + this.terminals[terminalToReuse.terminal.id.toString()].lastTask = taskKey; return [terminalToReuse.terminal, commandExecutable, undefined]; }