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 #82

Closed
wants to merge 4 commits into from

Conversation

rschnekenbu
Copy link

@rschnekenbu rschnekenbu commented Jun 20, 2023

What it does

Adds the close property to TaskPresentationOptions
This enables the possibility to close the terminal once the task is finished.

Fixes eclipse-theia#12611

Contributed on behalf of ST Microelectronics

How to test

  1. Install following extension:
  1. Copy the content of this archive at the root of your workspace:
    workspace-test.zip. It contains several tasks that can be identified by the sample extension. In the extension, the build tasks are supposed to close the terminal after the task is finished (close set to true) whereas the terminal should remain on completion for other tasks like test tasks.

  2. On master theia, the terminal always remain after the tasks are finished (this is also the default behavior after the patch when close is not defined.). The extension is written so the tasks are configured differently if they are build tasks or any other kind of tasks. This does not do any difference on master, as the close property is not known.
    12611-before

  3. Switch to this PR and run the same tests. The terminal will close for the build tasks, and remain open for reuse for the other tasks like test tasks.
    12611-after

Review checklist

Reminder for reviewers

@rschnekenbu
Copy link
Author

As a note: changelog will be updated when pushed to official repo.

terminal.busy = false;
terminal.scrollToBottom();
if (showReuseMessage) {
terminal.writeLine('\x1b[1m\n\rTerminal will be reused by tasks. \x1b[0m\n');
}
if (closeOnFinish) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't like that the terminal is closed in a message that is names notifyTaskFinished. A reader would not expect that from the name. Why not just do this at the (single) call site?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I vaguely remember that we reuse terminals for running tasks in some cases. If my recollection is correct, shouldn't we check if this is a shared terminal and keep it open in that case?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indeed, thanks for pointing out!
I renamed to a more generic term on handling the terminal on task exit, not only notifying the task was finished. That should be more readable from a developer point of view.

For the reuse terminal options, I tend to think that closing the terminal has a higher priority than sharing it with other tasks. I checked on VS Code, the behavior is coherent. Their close option prevails over the shared/dedicated option.

@@ -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);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems to me that if closeOnFinish defaults to true in TaskOutputPresentation.shouldCloseTerminalOnFinish. Is that the right default?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, the default was supposed to be 'false' and was badly implemented. Fixed with new patch.

@rschnekenbu rschnekenbu force-pushed the issues/12611 branch 2 times, most recently from 3e60edd to 452ec93 Compare July 20, 2023 09:30
@rschnekenbu
Copy link
Author

Thanks a lot for your review, Thomas! I pushed a new version of the branch, rebased on latest master. That should address the comments

* Adds close to the TaskPresentationOptions
* Checks when task is finished if terminal shall be closed

Contributed on behalf of STMicroelectronics
@rschnekenbu
Copy link
Author

Thanks @tsmaeder for the review!
I will close this one in favor of eclipse-theia#12749, with:

  • changelog updated
  • squashed and based on latest master

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[vscode] Support TaskPresentationOptions#close property
4 participants