From 35ee65d56cdd99e43d963695bd7f4844fb9bf3ba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Paul=20Mar=C3=A9chal?= Date: Thu, 8 Aug 2019 17:39:53 -0400 Subject: [PATCH] process: display process tasks in the terminal MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit `process` tasks aren't displayed in the terminal, whereas it is displayed as such in VS Code. This commit makes it so `process` tasks are displayed the same way `shell` tasks are. Signed-off-by: Paul Maréchal --- packages/task/src/browser/task-service.ts | 15 ++++++++++----- packages/task/src/node/process/process-task.ts | 4 ++-- packages/task/src/node/task-server.slow-spec.ts | 4 ++-- 3 files changed, 14 insertions(+), 9 deletions(-) diff --git a/packages/task/src/browser/task-service.ts b/packages/task/src/browser/task-service.ts index 5ce0c6f31d288..67119a76224c3 100644 --- a/packages/task/src/browser/task-service.ts +++ b/packages/task/src/browser/task-service.ts @@ -392,8 +392,13 @@ export class TaskService implements TaskConfigurationClient { this.logger.debug(`Task created. Task id: ${taskInfo.taskId}`); - // open terminal widget if the task is based on a terminal process (type: shell) - if (taskInfo.terminalId !== undefined) { + /** + * open terminal widget if the task is based on a terminal process (type: 'shell' or 'process') + * + * @todo Use a different mechanism to determine if the task should be attached? + * Reason: Maybe a new task type wants to also be displayed in a terminal. + */ + if (typeof taskInfo.terminalId === 'number') { this.attach(taskInfo.terminalId, taskInfo.taskId); } } @@ -436,7 +441,7 @@ export class TaskService implements TaskConfigurationClient { terminal.sendText(selectedText); } - async attach(terminalId: number, taskId: number): Promise { + async attach(processId: number, taskId: number): Promise { // Get the list of all available running tasks. const runningTasks: TaskInfo[] = await this.getRunningTasks(); // Get the corresponding task information based on task id if available. @@ -446,7 +451,7 @@ export class TaskService implements TaskConfigurationClient { TERMINAL_WIDGET_FACTORY_ID, { created: new Date().toString(), - id: 'terminal-' + terminalId, + id: 'terminal-' + processId, title: taskInfo ? `Task: ${taskInfo.config.label}` : `Task: #${taskId}`, @@ -455,7 +460,7 @@ export class TaskService implements TaskConfigurationClient { ); this.shell.addWidget(widget, { area: 'bottom' }); this.shell.activateWidget(widget.id); - widget.start(terminalId); + widget.start(processId); } async configure(task: TaskConfiguration): Promise { diff --git a/packages/task/src/node/process/process-task.ts b/packages/task/src/node/process/process-task.ts index 881f934c5f2c1..bed546979804e 100644 --- a/packages/task/src/node/process/process-task.ts +++ b/packages/task/src/node/process/process-task.ts @@ -124,8 +124,8 @@ export class ProcessTask extends Task { taskId: this.id, ctx: this.context, config: this.options.config, - terminalId: (this.processType === 'shell') ? this.process.id : undefined, - processId: this.processType === 'process' ? this.process.id : undefined + terminalId: this.process.id, + processId: this.process.id, }; } diff --git a/packages/task/src/node/task-server.slow-spec.ts b/packages/task/src/node/task-server.slow-spec.ts index b72ac58055023..34caed2995602 100644 --- a/packages/task/src/node/task-server.slow-spec.ts +++ b/packages/task/src/node/task-server.slow-spec.ts @@ -117,10 +117,10 @@ describe('Task server / back-end', function (): void { const p = new Promise((resolve, reject) => { const toDispose = taskWatcher.onTaskExit((event: TaskExitedEvent) => { if (event.taskId === taskInfo.taskId && event.code === 0) { - if (taskInfo.terminalId === undefined) { + if (typeof taskInfo.terminalId === 'number') { resolve(); } else { - reject(new Error(`terminal id was expected to be undefined, actual: ${taskInfo.terminalId}`)); + reject(new Error(`terminal id was expected to be a number, got: ${typeof taskInfo.terminalId}`)); } toDispose.dispose(); }