VS Code debugger no longer accepting input - visual-studio-code

Strangely, VS Code stopped accepting input from integrated and external terminals. It was working with fish as the shell on Arch an hour ago. If I run the following Python code, for example:
print('Please enter a number: ', end='')
a = float(input())
print(f'Your number is: {a}')
and I type 1 and hit Enter, the cursor moves to the next line and all execution halts. The debugger is still running as if I didn't enter anything, but the terminal is displaying my input. When I hit stop, I see the error "timeout after 1000ms" as an alert in the lower right of VS Code.
I haven't made any changes to launch.json after generating from the Python: Current File option. For clarity's sake, that code is here:
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "Python: Current File",
"type": "python",
"request": "launch",
"program": "${file}",
"console": "integratedTerminal"
}
]
}
I haven't found any resolution by reading the docs. Is this just a bug that will get fixed, or am I doing something wrong?
Edit
Executing the code from the shell normally runs as expected.

https://github.com/microsoft/vscode-python/issues/13449
check this out, try downgrade the extension back to another version.

Related

VSCode program output to integrated debug console instead of integrated terminal

According to documentation, I should be able to get my program output to display in the Integrated debug console instead of in the Integrated terminal with:
"programOutput": true in launch.json
In the simplest hello world C program on linux with vscode version 1.75.1, this just doesn't work. Both stderr, and stdout go to the integrated terminal.
By the way, the reason I want this to work is because I want to use the filter line to specify which output lines to show and which to hide.
"version": "0.2.0",
"configurations": [
{
"name": "(gdb) Launch",
"type": "cppdbg",
...
...
"externalConsole": false,
"logging": {
"programOutput": true
},

VS Code "localhost refused to connect" error when starting up launch.json on Mac

I have searched and searched and searched for days. I am at my wits end so please be patient with me. I am very new at this.
I have tried almost all suggestions on the net, to no avail.
When I try to launch launch.json in VS Code it goes straight to "localhost refused to connect" page. When I launch it via command line using "npm start", it is successful and no issues are found.
This is my launch.json file:
{
"version": "0.2.0",
"configurations": [
{
"type": "chrome",
"request": "launch",
"timeout": "10000",
"name": "Launch Chrome against localhost",
"url": "http://localhost:8080",
"webRoot": "${workspaceFolder}"
}
]
}`
When I try to add the following line to the configurations in launch.json:
"preLaunchTask": "npm: start"
It somewhat works. The page displays the content on localhost, but the debugger continues to load indefinitely, leaving me unable to press the green arrow to do it again. I have to go to the terminal in VS Code and "control + c" to shut it down but in doing so VS Code launches another localhost that refused to connect, at which point I can press run again to another successful page that seemed to have completely loaded.
At the same time it displays "localhost refused to connect" this displays in the debug console: "crbug/1173575, non-JS module files deprecated. ...mewebdata/(index)꞉6567:22:6792". This occurs when I remove the
"preLaunchTask": "npm: start"
from the launch.json file.
I have tried installing Live Server and running on localhost:5500 but it only gives me a directory of my files and not the actual content itself. I tried creating a tasks.json and a settings.json file. Nada. I've tried the ipconfig /flushdns equivalent on Mac. Nope.
I would rather not do it any of these ways. I want to press the run button and have Chrome open a localhost of my code successfully. That's all. What is missing here?
EDIT: I keep getting the error "Chrome didn't shut down properly" every time I run with the offer of restoring my page. I click the X in the top left corner to exit. Is that not what I'm supposed to do?

Can I run and debug deno project in VSCode?

I'm new to both typescript and deno, also vscode.
Firstly, I tried it with vscode and failed, and then tried with IntelliJ.
I can run and debug simple .ts file in Intellij with deno plugin.
But I want to know how to do this in vscode(also installed deno plugin, https://marketplace.visualstudio.com/items?itemName=denoland.vscode-deno).
My settings are...
.vscode/settings.json
{
"deno.enable": true,
"deno.lint": true,
"deno.unstable": true
}
.vscode/launch.json
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"request": "launch",
"name": "Launch Program",
"type": "pwa-node",
"program": "${workspaceFolder}/main.ts",
"cwd": "${workspaceFolder}",
"runtimeExecutable": "deno",
"runtimeArgs": [
"run",
"--unstable",
"--inspect",
"--allow-all"
],
"attachSimplePort": 9229
}
]
}
Example code
console.log("Hello, World!");
When I run this using by Run without Debugging
just shows like below image but expected to output Hello, World!.
and also seems debugging is not working.
Please help.
Debugging with --inspect does not work for relatively short programs, because it does not wait for the debugger to connect. So when running short programs the execution finishes before VS Code connects to the inspector. On larger programs this won't be an issue.
For debugging Deno programs that are only a couple of lines long, two options are given in this thread:
Use --inspect-brk instead of --inspect, this should allow enough time for the debugger to connect and hit breakpoints
Add some time delay to the code when debugging, for example:
const _sleep = async () => {
await new Promise(resolve => setTimeout(resolve, 2000));
}
await _sleep();
console.log("Hello World!"); <-- Here, you could add a breakpoint
To Run without Debugging, you can also either add --inspect-brk, but you will have to press F5 or click 'Continue' once the session has started. Or, you can use --inspect and add the sleep function

Why does R Debugger fail to verify all breakpoints (Vscode)

I am using R Debugger in Vscode to develop an RShiny app while using SSH to connect to the remote.
My launch.json file looks like this:
{
"version": "0.2.0",
"configurations": [
{
"type": "R-Debugger",
"name": "Launch R-Workspace",
"request": "launch",
"debugMode": "workspace",
"workingDirectory": "", // If I put my actual path here, it changes nothing
"allowGlobalDebugging":true
}
]
}
For the purposes of this topic, I have these folders/files:
src/www/uis
src/server.R
I set breakpoints in files within src/www/uis as well as within src/server.R.
When I use Launch R-Workspace, the breakpoints at src/www/uis will trigger but within src/server.r they turn into "unverified breakpoints".
What I've tried:
Reading through similar questions and findings answers that did not seem relevant. Reading through the documentation where I did not see anything useful to me.
Any insight?
Thanks

Node debugging, make `${file}` dynamic?

With the right debug config file I can make VSCode run the currently focussed file through Mocha. However, I find it frustrating that if I am working on the actual code, rather than the spec file and I press F5, it tries to run the actual code as a spec file through Mocha.
So, my question is; given a file structure like this:
Folder
File.js
File.spec.js
And a debug config (.vscode/launch.json) like this:
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"type": "node",
"request": "launch",
"name": "Unit Tests: Current File",
"program": "${workspaceRoot}/node_modules/.bin/_mocha",
"cwd": "${workspaceRoot}",
"args": [
"-u", "tdd",
"--timeout=999999",
"--colors",
"--opts", "${workspaceRoot}/mocha.opts",
"${file}" // I want to make this dynamic
],
}
]
}
Is it possible to get VSCode to debug the spec file whether the spec file (File.spec.js) or it's subject (File.js) are selected?
You can introduce a new dynamic variable by writing a simple extension that just defines one command, e.g. a smartFile command.
Then you can refer to that command in your launch config as ${command:smartFile}.
For the implementation of the command you can use everything available in VS Code extension API. So you can not only calculate a path based on your folder structure, but you can even pop-up UI. E.g. you could use QuickPick to select a test case from the list of all tests.