actboy168 / lua-debug

Lua Debug Adapter for Visual Studio Code
MIT License
439 stars 95 forks source link

Add externalConsole support. #57

Closed Xorcist77 closed 5 years ago

Xorcist77 commented 5 years ago

Presently any interactive Lua code run through the debugger will run within VSCode's internal console and will not accept user input (i.e io,read). Add a launch configuration option to use an external console.

actboy168 commented 5 years ago

You can use "console": "integratedTerminal" or "console": "externalTerminal".

Xorcist77 commented 5 years ago

This is a bit confusing. So by using that option, I have to perform my user input in one place and view the output in another... the Debug Console is used to see print() (but io.write() will not show) and the external terminal is used for io.read(), but the internal terminal will not accept input?

actboy168 commented 5 years ago

outputCapture can decide what will be displayed in the debug console.

Xorcist77 commented 5 years ago

I think I'm missing something... at a regular windows command prompt when I run "lua myscript.lua" and my script is as such:

io.write("Enter a number: "); x = io.read("*n"); print("You entered:" .. x);

I will get "Enter a number: " displayed with a waiting cursor at the end of the line and when I type a number and hit enter it then displays "You entered: #" on the next line. I can't seem to achieve that in any way with this extension. Any io.write() is not displayed in the debug console until after the script is finished (not as those lines of code are hit) and any user inputs have to be made in a separate external or internal terminal (neither of which output any prints or io.write statements), which is confusing at best.

I was hoping using the external terminal option would be the same as just running it externally of VSCode, but this does not seem to be the case.

If you know this is working, would you mind sharing a working launch.json file?

For reference: I am running Lua 5.3 on Windows 7 64bit with VSCode 1.33.1.

actboy168 commented 5 years ago

        {
            "type": "lua",
            "request": "launch",
            "name": "Test",
            "stopOnEntry": false,
            "console": "integratedTerminal",
            "program": "${file}",
            "outputCapture": []
        }
Xorcist77 commented 5 years ago

Thanks, that worked with "console": "externalTerminal", but not with the integrated one. I don't know if this is just an issue with Windows or not. But it appears I can now run the app like I would normally, but with the added ability to now set break points, etc. Thanks.