'Run Selected Text' action is not working when current terminal widget is completed task widget.
Run Selected Text action
OS and Theia version:
Ubuntu 18.04.1
Theia: ced3f90a3b1ebf6fcfaf5a62e082dcdfa1f0304c
Diagnostics:
I guess Run Selected Text action tries to use stopped task as current terminal widget.
I did some investigation, and found an intesting behavior in vs code: "Run Selected text" simply echos the selected text in the current terminal which has one task actively running, instead of running the selected text as a command (See the attached GIF). Is it the correct behavior ?
In my opninion, the "selected text" should always be run in an interactive terminal, no exceptions. If there is a task running in the current terminal, we should find an interactive terminal, or create an interactive terminal to execute the selected text as a command.
What do you think? @RomanNikitenko @vince-fugnitto @akosyakov @eclipse-theia/task-extension

In my opinion, the "selected text" should always be run in an interactive terminal, no exceptions.
I agree, I find it odd that vscode would use a busy terminal to display output of “run selected text”. In my opinion, the output would be lost in all the noise of a task which is currently under execution. I think we should opt for the simplest solution which is to look for an idle interactive terminal to run the text or create a terminal if none exist.
In my opninion, the "selected text" should always be run in an interactive terminal, no exceptions. If there is a task running in the current terminal, we should find an interactive terminal, or create an interactive terminal to execute the selected text as a command.
Agree.
For 'Run Selected Text' we should use:
would this solution work for you?

What it a definition of the idle terminal If i don't know about tasks?
What it a definition of the idle terminal If i don't know about tasks?
@akosyakov
as you know, "idle" is not a property of the terminal. so we have no idea if a terminal is idle.
that's why I proposed the solution of "only running selected text in an interactive terminal"
and we could use terminalWidget.hasRunningProcesses() to check if an interactive terminal is busy.
What do you think?
and we could use terminalWidget.hasRunningProcesses() to check if an interactive terminal is busy.
Terminal which does not run any task also has a running process (shell). How is it related to terminal be interactive? How do you define terminal interactive? That it can accept a user input? How could you check that a terminal process can accept a user input?
export interface TerminalWidget {
busy: boolean;
readonly onDidChangeBusy: Event<boolean>;
}
Or maybe we can introduce something like TerminalType with System and User kind, defaults to User. System kind means that a terminal was created by a product for some reasons and cannot be used to run random user scripts, e.g. for tasks. Then for this issue we will check whether a current terminal is User terminal and if not create a new User terminal. In both cases terminals can be interactive, i.e. if a task requires some input from a user.
I actually like it more, since it looks like terminals running task should disallow running a random user program and busy won't help with it. But System kind can resolve both issues.
terminal.kind will be introduced in https://github.com/eclipse-theia/theia/pull/7260. After it merged, this PR should be fixable by respecting only user terminals.
Most helpful comment
terminal.kindwill be introduced in https://github.com/eclipse-theia/theia/pull/7260. After it merged, this PR should be fixable by respecting onlyuserterminals.