diff --git a/packages/task/src/browser/task-service.ts b/packages/task/src/browser/task-service.ts index a7061a402f23a..0f600bc396d45 100644 --- a/packages/task/src/browser/task-service.ts +++ b/packages/task/src/browser/task-service.ts @@ -970,8 +970,8 @@ export class TaskService implements TaskConfigurationClient { selectedRange = Range.create(startLine, 0, endLine + 1, 0); } const selectedText: string = this.editorManager.currentEditor.editor.document.getText(selectedRange).trimRight() + '\n'; - let terminal = this.terminalService.currentTerminal; - if (!terminal) { + let terminal = this.terminalService.lastUsedTerminal; + if (!terminal || terminal.kind !== 'user' || (await terminal.hasChildProcesses())) { terminal = await this.terminalService.newTerminal({ created: new Date().toString() }); await terminal.start(); this.terminalService.activateTerminal(terminal);