diff --git a/CHANGELOG.md b/CHANGELOG.md index 9829e4dafd3c3..e55cdcda991a9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,7 @@ Breaking changes: - [scm] support file tree mode in Source Control view. Classes that extend ScmWidget will likely require changes [#7505](https://github.com/eclipse-theia/theia/pull/7505) +- [task] removed `taskId` from `TaskTerminalWidgetOpenerOptions` [#7765](https://github.com/eclipse-theia/theia/pull/7765) ## v1.1.0 diff --git a/packages/task/src/browser/task-service.ts b/packages/task/src/browser/task-service.ts index 62517a2878b40..28781035633de 100644 --- a/packages/task/src/browser/task-service.ts +++ b/packages/task/src/browser/task-service.ts @@ -326,7 +326,7 @@ export class TaskService implements TaskConfigurationClient { }); } - private getTaskIdentifier(taskConfig: TaskConfiguration): string { + protected getTaskIdentifier(taskConfig: TaskConfiguration): string { const taskName = this.taskNameResolver.resolve(taskConfig); const sourceStrUri = this.taskSourceResolver.resolve(taskConfig); return `${taskName} (${this.labelProvider.getName(new URI(sourceStrUri))})`; @@ -896,7 +896,7 @@ export class TaskService implements TaskConfigurationClient { return customizationObject; } - private async removeProblemMarkers(option?: RunTaskOption): Promise { + protected async removeProblemMarkers(option?: RunTaskOption): Promise { if (option && option.customization) { const matchersFromOption = option.customization.problemMatcher || []; for (const matcher of matchersFromOption) { @@ -910,7 +910,7 @@ export class TaskService implements TaskConfigurationClient { } } - private async getResolvedTask(task: TaskConfiguration): Promise { + protected async getResolvedTask(task: TaskConfiguration): Promise { let resolver = undefined; let resolvedTask: TaskConfiguration; try { @@ -930,7 +930,7 @@ export class TaskService implements TaskConfigurationClient { * @param resolvedTask the resolved task * @param option options to run the resolved task */ - private async runResolvedTask(resolvedTask: TaskConfiguration, option?: RunTaskOption): Promise { + protected async runResolvedTask(resolvedTask: TaskConfiguration, option?: RunTaskOption): Promise { const source = resolvedTask._source; const taskLabel = resolvedTask.label; try { @@ -955,7 +955,7 @@ export class TaskService implements TaskConfigurationClient { } } - private getCustomizeProblemMatcherItems(): QuickPickItem[] { + protected getCustomizeProblemMatcherItems(): QuickPickItem[] { const items: QuickPickItem[] = []; items.push({ label: 'Continue without scanning the task output', @@ -1035,7 +1035,6 @@ export class TaskService implements TaskConfigurationClient { : `Task: #${taskId}`, destroyTermOnClose: true }, { - taskId, widgetOptions: { area: 'bottom' }, mode: widgetOpenMode, taskInfo diff --git a/packages/task/src/browser/task-terminal-widget-manager.ts b/packages/task/src/browser/task-terminal-widget-manager.ts index 4c1ded00db3f0..cb35f082350a0 100644 --- a/packages/task/src/browser/task-terminal-widget-manager.ts +++ b/packages/task/src/browser/task-terminal-widget-manager.ts @@ -38,27 +38,27 @@ export namespace TaskTerminalWidget { } export interface TaskTerminalWidgetOpenerOptions extends WidgetOpenerOptions { - taskId: number; + taskConfig?: TaskConfiguration; taskInfo?: TaskInfo; } export namespace TaskTerminalWidgetOpenerOptions { export function isDedicatedTerminal(options: TaskTerminalWidgetOpenerOptions): boolean { - const taskConfig = options.taskInfo ? options.taskInfo.config : undefined; + const taskConfig = options.taskInfo ? options.taskInfo.config : options.taskConfig; return !!taskConfig && !!taskConfig.presentation && taskConfig.presentation.panel === PanelKind.Dedicated; } export function isNewTerminal(options: TaskTerminalWidgetOpenerOptions): boolean { - const taskConfig = options.taskInfo ? options.taskInfo.config : undefined; + const taskConfig = options.taskInfo ? options.taskInfo.config : options.taskConfig; return !!taskConfig && !!taskConfig.presentation && taskConfig.presentation.panel === PanelKind.New; } export function isSharedTerminal(options: TaskTerminalWidgetOpenerOptions): boolean { - const taskConfig = options.taskInfo ? options.taskInfo.config : undefined; + const taskConfig = options.taskInfo ? options.taskInfo.config : options.taskConfig; return !!taskConfig && (taskConfig.presentation === undefined || taskConfig.presentation.panel === undefined || taskConfig.presentation.panel === PanelKind.Shared); } export function echoExecutedCommand(options: TaskTerminalWidgetOpenerOptions): boolean { - const taskConfig = options.taskInfo ? options.taskInfo.config : undefined; + const taskConfig = options.taskInfo ? options.taskInfo.config : options.taskConfig; return !!taskConfig && (taskConfig.presentation === undefined || taskConfig.presentation.echo === undefined || taskConfig.presentation.echo); } } @@ -126,9 +126,15 @@ export class TaskTerminalWidgetManager { }); } + async newTaskTerminal(factoryOptions: TerminalWidgetFactoryOptions): Promise { + return this.terminalService.newTerminal({ ...factoryOptions, kind: 'task' }); + } + async open(factoryOptions: TerminalWidgetFactoryOptions, openerOptions: TaskTerminalWidgetOpenerOptions): Promise { + const taskInfo = openerOptions.taskInfo; + const taskConfig = taskInfo ? taskInfo.config : openerOptions.taskConfig; const dedicated = TaskTerminalWidgetOpenerOptions.isDedicatedTerminal(openerOptions); - if (dedicated && (!openerOptions.taskInfo || !openerOptions.taskInfo.config)) { + if (dedicated && !taskConfig) { throw new Error('"taskConfig" must be included as part of the "option.taskInfo" if "isDedicated" is true'); } @@ -140,13 +146,12 @@ export class TaskTerminalWidgetManager { if (factoryOptions.title) { widget.setTitle(factoryOptions.title); } - const taskConfig = openerOptions.taskInfo ? openerOptions.taskInfo.config : undefined; if (taskConfig && TaskOutputPresentation.shouldClearTerminalBeforeRun(taskConfig)) { widget.clearOutput(); } } this.terminalService.open(widget, openerOptions); - const taskInfo = openerOptions.taskInfo; + if (TaskTerminalWidgetOpenerOptions.echoExecutedCommand(openerOptions) && taskInfo && ProcessTaskInfo.is(taskInfo) && taskInfo.command && taskInfo.command.length > 0 ) { @@ -159,14 +164,15 @@ export class TaskTerminalWidgetManager { factoryOptions: TerminalWidgetFactoryOptions, openerOptions: TaskTerminalWidgetOpenerOptions ): Promise<{ isNew: boolean, widget: TerminalWidget }> { let reusableTerminalWidget: TerminalWidget | undefined; + const taskConfig = openerOptions.taskInfo ? openerOptions.taskInfo.config : openerOptions.taskConfig; if (TaskTerminalWidgetOpenerOptions.isDedicatedTerminal(openerOptions)) { for (const widget of this.getTaskTerminalWidgets()) { // to run a task whose `taskPresentation === 'dedicated'`, the terminal to be reused must be // 1) dedicated, 2) idle, 3) the one that ran the same task if (widget.dedicated && !widget.busy && - widget.taskConfig && openerOptions.taskInfo && - this.taskDefinitionRegistry.compareTasks(openerOptions.taskInfo.taskConfig, widget.taskConfig)) { + widget.taskConfig && taskConfig && + this.taskDefinitionRegistry.compareTasks(taskConfig, widget.taskConfig)) { reusableTerminalWidget = widget; break; @@ -190,17 +196,17 @@ export class TaskTerminalWidgetManager { // we are unable to find a terminal widget to run the task, or `taskPresentation === 'new'` if (!reusableTerminalWidget) { - const widget = await this.terminalService.newTerminal({ ...factoryOptions, kind: 'task' }); + const widget = await this.newTaskTerminal(factoryOptions); return { isNew: true, widget }; } return { isNew: false, widget: reusableTerminalWidget }; } - private getTaskTerminalWidgets(): TaskTerminalWidget[] { + protected getTaskTerminalWidgets(): TaskTerminalWidget[] { return this.terminalService.all.filter(TaskTerminalWidget.is); } - private notifyTaskFinished(terminal: TaskTerminalWidget, showReuseMessage: boolean): void { + protected notifyTaskFinished(terminal: TaskTerminalWidget, showReuseMessage: boolean): void { terminal.busy = false; terminal.scrollToBottom(); if (showReuseMessage) {