You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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)
The text was updated successfully, but these errors were encountered:
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
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
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:
Console.ReadLine
(typing into the debug window always behaves like a REPL, so you can't provide any input toReadLine
!)Console.ReadKey
:'System.InvalidOperationException' in System.Console.dll
PowerShell
Also embeds in debug window:
Read-Host
works!$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)The text was updated successfully, but these errors were encountered: