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

What is the expected behaviour for an extension launching/debugging a console app? #10514

Closed
DanTup opened this issue Aug 14, 2016 · 2 comments
Closed
Assignees
Labels
debug Debug viewlet, configurations, breakpoints, adapter issues *question Issue represents a question, should be posted to StackOverflow (VS Code)

Comments

@DanTup
Copy link
Contributor

DanTup commented Aug 14, 2016

We're adding the ability to run console apps to Dart Code and trying to figure out the best way to do it. With the current implementation runs the process is hidden and stdin is routed to the debug console. I'm worried about how this would affect reading input (such as keypresses) from the user and not behaving the same as if it was run from a traditional shell.

I did a little bit of testing with the Posh and C# extensions and I was surprised not only because they do the same, but because the C# one seemed to totally fail on Console.ReadLine and Console.ReadKey!

So I wondered whether there was any guidance on this? I was originally expected it to work like a console app in Fat VS - a new window spawns and it works just like I'd executed it from the Windows Run dialog. I'd like to keep things consistent with other Code experiences, but not being able to read from stdin correctly seems like a serious flaw.

Advice welcome!

Findings:

C# (.NET Core)

Embeds in the debug window but appears to:

  • Hang on Console.ReadLine (typing into the debug window always behaves like a REPL, so you can't provide any input to ReadLine!)
  • Exception thrown on Console.ReadKey: 'System.InvalidOperationException' in System.Console.dll

PowerShell

Also embeds in debug window:

  • Read-Host works!
  • Input box works as a REPL when the process is suspended/at a breakpoint but otherwise gets sent to STDIN
  • Reading a single key does not work (though that's done a bit weird in PoSh - $Host.UI.RawUI.ReadKey('NoEcho,IncludeKeyDown'))
  • Write-Progress doesn't fail, but doesn't show progress (this is expected behaviour, Write-Process is designed not to crash when a host doesn't support it)
@weinand weinand added *question Issue represents a question, should be posted to StackOverflow (VS Code) debug Debug viewlet, configurations, breakpoints, adapter issues labels Aug 15, 2016
@weinand
Copy link
Contributor

weinand commented Aug 15, 2016

VS Code's builtin 'node-debug' shows the two possible options for launching a console program.

  • using VS Code's builtin debug console (property externalConsole set to false):
    this is node-debug's default. The debug adapter launches the program (aka 'debug target') and reads its stdin and stderr and forwards this as 'output' events to VS Code which shows the data in the debug console. Since the debug console is at the same time a REPL, typed input is not sent to the debug target but is 'evaluated'. This makes it impossible for the debug target to read from the console. So the builtin console works fine for developing applications that only send logging information to stdout or stderr and do not read input.
  • using an external console (property externalConsole set to true):
    the node-debug adapter supports to launch the debug target in an external console. In this mode stdout/stderr and stdin of the debug target is connect to a native terminal (a real 'tty' in unix parlance) and all features of the console are available. VS Code is not involved in processing the input or output of the debug target. Since this feature is independent from VS Code, it is optional and must be implemented in the debug adapter for all platforms (and not all debug extensions go through the effort to support this).

What we plan:

Since VS Code got a new 'real' builtin terminal, we are planning to support this as a platform independent 'third' option to run a debug target. It would behave like the second option from above but the effort to support it in the debug extension would be trivial and we expect every debug extension to support it. The corresponding feature request is this: #10574

Summary:

if your debug extension needs to support development of console applications today do the same what node-debug does (see https://github.com/Microsoft/vscode-node-debug/blob/master/src/node/terminal.ts).
In the future you will be able to use VS Code's builtin terminal.

/cc @Tyriar @isidorn

@Tyriar
Copy link
Member

Tyriar commented Aug 15, 2016

#9957 is the terminal API feature request for august.

@vscodebot vscodebot bot locked and limited conversation to collaborators Nov 18, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
debug Debug viewlet, configurations, breakpoints, adapter issues *question Issue represents a question, should be posted to StackOverflow (VS Code)
Projects
None yet
Development

No branches or pull requests

3 participants