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

fix #6767: don't reuse integrated terminal that has child processes #6769

Conversation

a1994846931931
Copy link
Contributor

@a1994846931931 a1994846931931 commented Dec 18, 2019

Signed-off-by: Cai Xuye a1994846931931@gmail.com

What it does

Fix #6767.

How to test

  1. Check whether the reuse of the integrated terminal is still working.
  2. Check if an integrated terminal is in use, it won't be reused.
    Demo gif for the 1st commit (propose 1 in Integrated terminal should not be resused if a process is running in it #6767):
    integrated-terminal-fixed
  3. Check if the title of the integrated terminal keeps its original value
    Update gif for the 2nd commit (propose 2 in Integrated terminal should not be resused if a process is running in it #6767):
    integrated-terminal-fixed2

I've tested in only on Linux. Could anyone test it on windows as well? Thanks!

Review checklist

Reminder for reviewers

@akosyakov akosyakov added debug issues that related to debug functionality terminal issues related to the terminal labels Dec 18, 2019
@paul-marechal
Copy link
Member

Thanks for the patch @a1994846931931, please note that I am working on the shell argument escaping for the runInTerminal request, I don't know if you had issues with this too.

@a1994846931931
Copy link
Contributor Author

a1994846931931 commented Dec 19, 2019

Thanks for the patch @a1994846931931, please note that I am working on the shell argument escaping for the runInTerminal request, I don't know if you had issues with this too.

@marechal-p
Hi, I do notice that we simply join the argument before sending it as the command to terminal:

terminal.sendText(args.join(' ') + '\n');

which may be problematic, while VSCode's implementation is far more complicated:
https://github.com/microsoft/vscode/blob/4636be2b71c87bfb0bfe3c94278b447a5efcc1f1/src/vs/workbench/contrib/debug/node/terminals.ts#L79-L210

Although I haven't encountered any broken issues so far, it reminds me of a line in cdt-gdb-adapter:
https://github.com/eclipse-cdt/cdt-gdb-adapter/blob/7b04c93f7e3a0646f6be5b6eac45c5f071e04829/src/GDBBackend.ts#L67

        let args = [gdb, '-ex', `new-ui mi2 ${pty.name}`];

where the argument new-ui mi2 ${pty.name} should be quoted before being send as a text command.
So I tested it on theia, and it does have a problem:
image
image

I hope the information helpful.

…d processes

Signed-off-by: Cai Xuye <a1994846931931@gmail.com>
Signed-off-by: Cai Xuye <a1994846931931@gmail.com>
@a1994846931931 a1994846931931 force-pushed the fix-reuse-integrated-terminal branch from c8ff6d6 to 44d87e7 Compare December 19, 2019 02:16
@paul-marechal
Copy link
Member

Yes, thank you for the infos. So again, just so that we do not duplicate work: I already have a commit for the command escaping, I will open and attend a PR with it first week of January as I will be taking vacations. With your patch + the commit I made, we should be pretty close to what VS Code does :)

@a1994846931931
Copy link
Contributor Author

Yes, thank you for the infos. So again, just so that we do not duplicate work: I already have a commit for the command escaping, I will open and attend a PR with it first week of January as I will be taking vacations. With your patch + the commit I made, we should be pretty close to what VS Code does :)

@marechal-p
Ah, I see! Thanks for reminding me. And luckily, this PR seems will not conflict with yours~

@akosyakov
Copy link
Member

@elaihau @vince-fugnitto @marechal-p please finish the review

@@ -41,4 +43,46 @@ export class ShellTerminalServer extends BaseTerminalServer {
return Promise.resolve(-1);
}
}

// copied and modified from https://github.com/microsoft/vscode/blob/4636be2b71c87bfb0bfe3c94278b447a5efcc1f1/src/vs/workbench/contrib/debug/node/terminals.ts#L32-L75
Copy link
Member

Choose a reason for hiding this comment

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

I created a CQ for the following copied code:
https://dev.eclipse.org/ipzilla/show_bug.cgi?id=21340

Copy link
Member

@paul-marechal paul-marechal left a comment

Choose a reason for hiding this comment

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

Changes LGTM, shells are also not reused if a process is already running. Should be good to merge once the CQs are resolved.

Copy link
Contributor

@elaihau elaihau left a comment

Choose a reason for hiding this comment

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

I played with the change and found the following behavior - should this scenario be covered by this change? Maybe it is unrelated?

Peek 2019-12-19 21-48

@a1994846931931
Copy link
Contributor Author

a1994846931931 commented Dec 20, 2019

I played with the change and found the following behavior - should this scenario be covered by this change? Maybe it is unrelated?

@elaihau
No, it's not covered in this PR. But similar behavior could be realized, by changing:


to

if (!terminal || (await terminal.hasChildProcesses())) {

after this commit.

Nevertheless, however, I'm not sure whether the Run selected text command should open a new terminal when the current one is running a program. I just tested it on VSCode, and it actually sends the text directly to the current one, even if it's running a program.
run-selected-text

@vince-fugnitto
Copy link
Member

The CQ has finally been approved! 🍾

@akosyakov
Copy link
Member

@a1994846931931 please merge!

@a1994846931931 a1994846931931 merged commit 7097574 into eclipse-theia:master Jan 21, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
debug issues that related to debug functionality terminal issues related to the terminal
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Integrated terminal should not be resused if a process is running in it
5 participants