Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

process: display process tasks in the terminal #5895

Merged
merged 1 commit into from
Aug 13, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 10 additions & 5 deletions packages/task/src/browser/task-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
Expand Down Expand Up @@ -436,7 +441,7 @@ export class TaskService implements TaskConfigurationClient {
terminal.sendText(selectedText);
}

async attach(terminalId: number, taskId: number): Promise<void> {
async attach(processId: number, taskId: number): Promise<void> {
// 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.
Expand All @@ -446,7 +451,7 @@ export class TaskService implements TaskConfigurationClient {
TERMINAL_WIDGET_FACTORY_ID,
<TerminalWidgetFactoryOptions>{
created: new Date().toString(),
id: 'terminal-' + terminalId,
id: 'terminal-' + processId,
title: taskInfo
? `Task: ${taskInfo.config.label}`
: `Task: #${taskId}`,
Expand All @@ -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<void> {
Expand Down
4 changes: 2 additions & 2 deletions packages/task/src/node/process/process-task.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
};
}

Expand Down
4 changes: 2 additions & 2 deletions packages/task/src/node/task-server.slow-spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Expand Down