VS Code Terminal Not Allowing Typing - visual-studio-code

My VS code terminal was working fine, until one day when I tried to work on a project, that was still open in VS code, my terminal didn't allow me to type any commands. I couldn't type anything. This is the screen that I get.

Okay, for those of you struggling with the same problem, I've managed to solve it by clicking on the drop-down menu that says powershell and changing it to cmd.

this happened to me and simply
close vs code
right click on it
run as administrator
open the terminal and it will work
this problem happened when I changed the default path of CMD

For me, I tried using Powershell/CMD/Bash and I was having errors/blank terminal. I found typing echo hello and pressing CTRL + C made it appear. So in fact, everything was working, my terminal was just blank/glitched out, but was really accepting input.

I had a similar issue when running ionic serve command which runs the development server on the localhost. I paid attention after executing the command above, and it said:
Use Ctrl+C to quit this process
Pressing Ctrl+C then displays:
Terminate batch job (Y/N)?
Type Y or y
then the command prompt is shown again!
Here is a sample terminal window - trimmed for brevity:

For who has this problem using React. This happens when you start a live version using npm start. The terminal that handles the live version of the app cannot be used for anything else.
So to continue using the terminal you need to open a new terminal to use in parallel. To do so just click on the plus icon in the top right corner of the terminal panel then choose the "Power Shell" option. This will open a new terminal without restarting visual studio.

In Mac, when working with Python, this helped me: instead of clicking on the "Run Code" option, click on "Run Python file", in the right corner.

For Ubuntu users this is solved by this solution:
File -> Preferences -> Setting -> Features -> Terminal -> Inherit Env

I found two vscode on my desktop, I opened the other one and it worked. Looks like I updated it but the older one didn't disappear.

If typing Ctrl+C can help to get out of this frozen state, that will be easier to do with VSCode 1.64 (Jan. 2022)
The terminal can type the answer for you.
Terminal -- Auto-reply
The terminal is now able to automatically reply when a specific sequences of characters is received.
A good example of where this is useful, which is also the only default case, is the Windows batch script message Terminate batch job (Y/N)? after hitting Ctrl+C when running a batch script.
This typically just ends up causing problems for the user.
The terminal will now automatically reply with Y and enter (\r) which makes Ctrl+C in Windows feel much better.
Pressing Ctrl+C will immediately reply to the question and return to the prompt:
Theme: Sapphire
The feature was made generically so you can setup custom replies for other thing, just be careful when doing this as you are sending text to the process automatically.
For example you could use it to automatically update Oh My Zsh when prompted:
"terminal.integrated.autoReplies": {
"[Oh My Zsh] Would you like to check for updates? [Y/n]": "Y\r"
}
If you use Clink and enable their similar feature, you can disable it in Clink or in VS Code by setting the reply to null to avoid the two features conflicting with each other:
"terminal.integrated.autoReplies": {
"Terminate batch job (Y/N)": null
}

Go to terminal, preferences, settings.
Check "run code in terminal"
Restart VS.

I changed from bash to powershell in terminal first but the command prompt still not shown.
Then I navigate to File -> Perferences -> Settings and it starts working (command prompt shown)

This seems to just be a display problem. It happened to me when I changed my display settings for desktop icon and app scaling settings.
I managed to fix the problem by simply restarting my computer and re-opening VS code

I had the same problem ... In my case just run vs-code as administrator and works

Related

Resize the terminal in vscode is trigger the ctrl+c to terminate the running command

I'm running the vscode 1.64.2 on Windows 10. Currently i met a strange problem, When i resize the terminal in the vscode and the cursor is focus on the terminal, Then it will trigger ctrl+c . At this time any running command would be terminated immediately .
To avoid this i have to un-focus for the terminal first and then resize it. Any suggestion here?
I was searching about this with no luck. Today I realized about one installed software on my machine that has a global hook on mouse selection. In my case was the QTranslate software. When I exit the application the problem was solved.
Check if you have this or another software that has a global hook on mouse selection.
In VS Code this problem (control C) was happening for any command line inside the terminal. Apart from that, opening Git bash (standalone) I was having the same issue, but not for cmd or another command line.
Hope this helps you because this was driving me crazy.
Absolutely working solution!
I experienced the same problem with mouse strange behavior for a long time, but finally I found out it was the QTranslate's guilt! After I stopped it, the problem has gone. (can't vote up because of my virgin profile here).
PS: I found the solution how to push work both QTranslate and terminal window - just set QTranslate setting "Advanced->Copy action" to "Ctrl+Insert" instead of Ctrl+C.

What settings do I have to change to make Visual Studio Code automatically run files in the right directory?

Coming from IDLE, I am used to be able to just left-click python files anywhere, it'll launch IDLE, and then pressing F5 just runs the script. In VSCode however, I have to open the terminal, cd into the right directory, and only then can I finally run my python script. Is there a way to change this behavior?
I was recommended to use the Code Runner extention and bound the Run Code (code-runner.run) command to my F5 key.
Then I noticed input() not being ran so I had to make sure code-runner.runInTerminal was on, but that re-started my problem from the beginning because the terminal was at the wrong working directory and then I finally found the code-runner.fileDirectoryAsCwd setting to run it from there.
I think this solution is similar to this one for the python extention, but I'm not sure if that would cause the whole wrong working directory issue again.
choose from menu file then click on auto save

How to manually restart an extension in VSCode?

I just allowed an update to the PowerShell extension, and I'm now presented with this notice:
PackageManagement updated. If you already had PackageManagement loaded in your session, please restart the PowerShell extension.
I would love to know how to do this. I imagine a full VSCode restart would do the trick, but curiosity has got the better of me here. Someday I might need to do this without interrupting other work in progress.
Apparently it can be accomplished programmatically, but before we go there it'd be nice to know how to do it manually.
On the Manage menu for the extension, we have the Disable and Uninstall items:
...but no Restart.
Can this be done?
Not sure how to do that programmatically, but you can restart the PowerShell session by opening the "PowerShell Session Menu" and then click "Restart Current Session". See below:
I was wondering the same thing for the powershell extension, and by poking around I found a potential solution (more of a workaround honestly):
Hit the "Kill terminal" button (trashbin icon)
KillTerminal (requires killing all active terminals)
The following dialogue appears, click "Yes" to restart it:
RestartDialogue
I confirmed too that the version did update: UpdateConfirmed
Press Ctrl + Shift + P to Open Command Palette and Type Restart Extension Host

Can't open VSCode from command-line WSL ZSH

So I decided to quit dual-boot and start using WSL. I'm having a problem and really can figure out how to fix it.
I simply can't open VSCode using the code command from the terminal when using an external terminal. When using the integrated, a command like "code ." works just fine.
Anyone knows how to fix it? It was working good a few steps of setup ago, but I lost track and don't exactly when that happened. I'm currently using HyperJS as terminal and my integrated terminal is already running zsh and it works when the VSCode is connected to WSL and when it isn't aswell.
Anyway, hoping for a fix, 'cause I'm really lost.
Thanks!
It's fixed and it was an easy fix, but it took long for me to realize that all I had to do was one step.
Here's the thing: the command "code" on the integrated terminal was working like a charm because the VSCode itself was running as administrator on Windows.
My Hyper wasn't running as administrator, so all I did was:
Right-click on HyperJS icon and go to the properties of the application
Switch to "Compatibility" tab
Check the "Run as administrator"
It's working without a problem now. Took me a while to realize that, but it's all good now.

Why is my command prompt freezing on Windows 10?

I'm adding this question after spending an entire day wrestling with this incredibly frustrating feature of the Windows 10 command prompt which made me think there was something wrong with my console application code. I hope it will help someone.
Issue: My console application seems to randomly stop running. What is going on?
The issue ended up being a new feature of the windows 10 console. Under the default config, whenever you click on a command window in windows 10, it immediately halts the application process when it attempts to write to the console. When this happens, the command window has gone into "selection" mode.
You can tell it has happened because it will prefix the title bar of the command window with the word "Select" :
To get your program running again, you have to press escape or click somewhere else.
To get rid of this strange behavior, you can disable QuickEdit mode:
What I'd like to add here to Shaun Rowan's answer is that for it to work in all console windows you have to click "Defaults", instead of "Properties" and make your changes there, as described in this post.
I faced this problem very recently where one of the users (who had Quickedit configured on his Command Prompt) was using a tool I developed in Java, and was getting the tool frozen while running it from command prompt.
Finally what solved the problem was to redirect the logging inside the batch script to a file as shown below:
#echo off
...
java.exe -jar mytool.jar
needed to be updated to
java.exe -jar mytool.jar > log.txt