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

[vscode] support TaskPresentationOptions close #12749

Merged
merged 1 commit into from
Jul 25, 2023
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
5 changes: 3 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

<a name="breaking_changes_1.40.0">[Breaking Changes:](#breaking_changes_1.40.0)</a>

Expand Down
1 change: 1 addition & 0 deletions packages/plugin-ext/src/common/plugin-api-rpc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1517,6 +1517,7 @@ export interface TaskPresentationOptionsDTO {
panel?: number;
showReuseMessage?: boolean;
clear?: boolean;
close?: boolean;
}

export interface TaskExecutionDto {
Expand Down
3 changes: 3 additions & 0 deletions packages/plugin/src/theia.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

/**
Expand Down
15 changes: 9 additions & 6 deletions packages/task/src/browser/task-terminal-widget-manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
Expand All @@ -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();
Expand Down Expand Up @@ -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');
}
}
Expand Down
11 changes: 9 additions & 2 deletions packages/task/src/common/task-protocol.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand All @@ -59,7 +60,8 @@ export namespace TaskOutputPresentation {
focus: false,
panel: PanelKind.Shared,
showReuseMessage: true,
clear: false
clear: false,
close: false
};
}

Expand Down Expand Up @@ -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;
Expand All @@ -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;
}
Expand Down
Loading