diff --git a/CHANGELOG.md b/CHANGELOG.md index f1a14b317e024..b395983b36315 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,9 +6,10 @@ ## v1.40.0 - -- [workspace] Implement CanonicalUriProvider API #12743 (https://github.com/eclipse-theia/theia/pull/12743 - Contributed on behalf of STMicroelectronics -- Show command shortcuts in toolbar item tooltips. #12660 (https://github.com/eclipse-theia/theia/pull/12660) - Contributed on behalf of STMicroelectronics +- [workspace] Implement CanonicalUriProvider API [#12743](https://github.com/eclipse-theia/theia/pull/12743) - Contributed on behalf of STMicroelectronics +- Show command shortcuts in toolbar item tooltips. [#12660](https://github.com/eclipse-theia/theia/pull/12660) - Contributed on behalf of STMicroelectronics - [cli] added `check:theia-extensions` which checks the uniqueness of Theia extension versions [#12596](https://github.com/eclipse-theia/theia/pull/12596) - Contributed on behalf of STMicroelectronics +- [vscode] Add support for the TaskPresentationOptions close property [#12749](https://github.com/eclipse-theia/theia/pull/12749) - Contributed on behalf of STMicroelectronics [Breaking Changes:](#breaking_changes_1.40.0) diff --git a/packages/plugin-ext/src/common/plugin-api-rpc.ts b/packages/plugin-ext/src/common/plugin-api-rpc.ts index 7e976a93f2303..50b5147920d10 100644 --- a/packages/plugin-ext/src/common/plugin-api-rpc.ts +++ b/packages/plugin-ext/src/common/plugin-api-rpc.ts @@ -1517,6 +1517,7 @@ export interface TaskPresentationOptionsDTO { panel?: number; showReuseMessage?: boolean; clear?: boolean; + close?: boolean; } export interface TaskExecutionDto { diff --git a/packages/plugin/src/theia.d.ts b/packages/plugin/src/theia.d.ts index a8e0bc8b3b075..49551a05b5ecc 100644 --- a/packages/plugin/src/theia.d.ts +++ b/packages/plugin/src/theia.d.ts @@ -12628,6 +12628,9 @@ export module '@theia/plugin' { /** Controls whether the terminal is cleared before executing the task. */ clear?: boolean; + + /** Controls whether the terminal is closed after executing the task. */ + close?: boolean; } /** diff --git a/packages/task/src/browser/task-terminal-widget-manager.ts b/packages/task/src/browser/task-terminal-widget-manager.ts index f14a6b4b8f85a..01be5628aab92 100644 --- a/packages/task/src/browser/task-terminal-widget-manager.ts +++ b/packages/task/src/browser/task-terminal-widget-manager.ts @@ -93,7 +93,8 @@ export class TaskTerminalWidgetManager { for (const terminal of this.getTaskTerminalWidgets()) { if (terminal.taskId === finishedTaskId) { const showReuseMessage = !!event.config && TaskOutputPresentation.shouldShowReuseMessage(event.config); - this.notifyTaskFinished(terminal, showReuseMessage); + const closeOnFinish = !!event.config && TaskOutputPresentation.shouldCloseTerminalOnFinish(event.config); + this.updateTerminalOnTaskExit(terminal, showReuseMessage, closeOnFinish); break; } } @@ -113,11 +114,11 @@ export class TaskTerminalWidgetManager { terminal.taskConfig = taskConfig; terminal.busy = true; } else { - this.notifyTaskFinished(terminal, true); + this.updateTerminalOnTaskExit(terminal, true, false); } }); const didConnectFailureListener = terminal.onDidOpenFailure(async () => { - this.notifyTaskFinished(terminal, true); + this.updateTerminalOnTaskExit(terminal, true, false); }); terminal.onDidDispose(() => { didConnectListener.dispose(); @@ -211,10 +212,12 @@ export class TaskTerminalWidgetManager { return this.terminalService.all.filter(TaskTerminalWidget.is); } - protected notifyTaskFinished(terminal: TaskTerminalWidget, showReuseMessage: boolean): void { + protected updateTerminalOnTaskExit(terminal: TaskTerminalWidget, showReuseMessage: boolean, closeOnFinish: boolean): void { terminal.busy = false; - terminal.scrollToBottom(); - if (showReuseMessage) { + if (closeOnFinish) { + terminal.close(); + } else if (showReuseMessage) { + terminal.scrollToBottom(); terminal.writeLine('\x1b[1m\n\rTerminal will be reused by tasks. \x1b[0m\n'); } } diff --git a/packages/task/src/common/task-protocol.ts b/packages/task/src/common/task-protocol.ts index af24fa5ab2812..3e32f3d7b4d1c 100644 --- a/packages/task/src/common/task-protocol.ts +++ b/packages/task/src/common/task-protocol.ts @@ -48,6 +48,7 @@ export interface TaskOutputPresentation { panel?: PanelKind; showReuseMessage?: boolean; clear?: boolean; + close?: boolean; // eslint-disable-next-line @typescript-eslint/no-explicit-any [name: string]: any; } @@ -59,7 +60,8 @@ export namespace TaskOutputPresentation { focus: false, panel: PanelKind.Shared, showReuseMessage: true, - clear: false + clear: false, + close: false }; } @@ -90,7 +92,8 @@ export namespace TaskOutputPresentation { echo: task.presentation.echo === undefined || task.presentation.echo, focus: shouldSetFocusToTerminal(task), showReuseMessage: shouldShowReuseMessage(task), - clear: shouldClearTerminalBeforeRun(task) + clear: shouldClearTerminalBeforeRun(task), + close: shouldCloseTerminalOnFinish(task) }; } return outputPresentation; @@ -108,6 +111,10 @@ export namespace TaskOutputPresentation { return !!task.presentation && !!task.presentation.clear; } + export function shouldCloseTerminalOnFinish(task: TaskCustomization): boolean { + return !!task.presentation && !!task.presentation.close; + } + export function shouldShowReuseMessage(task: TaskCustomization): boolean { return !task.presentation || task.presentation.showReuseMessage === undefined || !!task.presentation.showReuseMessage; }