From d96e6f17097b0941075c497f1d61398c1d0c15f8 Mon Sep 17 00:00:00 2001 From: Liang Huang Date: Mon, 6 Apr 2020 07:51:32 -0400 Subject: [PATCH] only run selected texts in a user terminal - The selected texts are only run in a user terminal. If the terminal widget that has the focus 1) is not a user terminal, or 2) is a user terminal that has an actively running command, Theia should create a new user terminal and run the selected texts in that new terminal. - fixes #7323 Signed-off-by: Liang Huang --- packages/task/src/browser/task-service.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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);