-
Notifications
You must be signed in to change notification settings - Fork 29.8k
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
Integrated Terminal: ctrl-c doesn't work in PowerShell and cmd.exe #9347
Comments
I haven't tried it in previous builds so I'm not sure whether it ever worked. |
Yeah, it's never worked for me. |
Any update on this? |
This might be caused by psreadline. I need to test it when I get a chance. I know I've noticed that it sometimes works and sometimes doesn't work. Also, sometimes if you click into a different part of the terminal and try it will work, but other times doing the same thing doesn't work. Ctrl+c doesn't work most often when a long running command is started. Shorter commands seem to have a better chance of worling if I recall. I often have to close the terminal out and open a new one because no matter what I try it won't stop. I started work on documenting the impact of Psreadline on the terminal late last week here. https://github.com/gerane/LineEndings However, I got sick and am still not totally better so I haven't been able to work on it. I'm trying to help get as many of the issues documented with examples so we can start determining how we can improve the experience with powershell. Since windows 8 PSreadline is bundled with the OS and gets imported by default in ConesoleHost, so there are likely a lot of people who see these issues. Another issue caused by Psreadline is ctrl+c for copy doesn't work in the prompt, only when highlighting in the output. At least I'm assuming it's caused by psreadline, haven't gotten to testing that yet. I'll try to work on documenting the ctrl+c issues when I'm feeling better. I was starting to talk with @daviwil @Tyriar and a few others about it last week, but then I started to get sick. |
I've recently started using the VSCode terminal for Powershell commands. (Windows v1.8.1.) I open the terminal, type Powershell then run commands. I'm used to hitting control-C to clear the input line when I mistype a command or change my mind, but this does not clear the line in VSCode terminal as it does in the native console, so I have to backspace the entire line. I mention this in case it's helpful/related to this issue, as it seems to me it might be. |
I heeded some of the comments here alluding to it being PSReadline so I removed it, and can confirm it still happens even with PSReadline removed. The only difference being that PSReadline will echo the |
Upstream issue: microsoft/node-pty#7 |
I noticed this as well and have some data that may (or may not) be helpful. It looks like Ctrl-C is sent to C# applications as |
I fixed this on my own copy - the issue was src/agent/ConsoleInput.cc:398 which should not depend on the input mode: if (input[0] == '\x03') {
// ... and line 403, the early return in that block, should be deleted. I'm not sure how this affects other uses of winpty, but it fixes Ctrl-C in the VSCode console for me. Here's a patched copy of winpty-agent.exe for anyone that needs this now (64-bit) - replace |
So what's the status on this? If I use If I use If I use Windows 10 pro fully patched as of today using v1.16.0 of VS Code. |
I can confirm @parkovski commented on Sep 13, 2017 patched winpty-agent works with Win10 x64 and PowerShell terminal.
|
The proffered solutions do not work for me, when opening a fresh terminal with |
ctrl+break works for me. However, some keyboards wont have a break key and you will need to determine the mapping. On my dell laptop Break is mapped to ctrl+fn+b, which appears to act like ctrl+c did formally. |
This is a regression for me. I downloaded Jan 2018 update and this started happening again. There are many closed issues on this bug tracker for this strange problem already. For me it's vscode -> Ctrl+Shift+C -> terminal opens -> run any process -> Ctrl-C does not kill the process. It's somehow swallowed. |
VSCode terminal window is dead to me. I've seen the issues as well with no movement on them. So I gave up on it. In fact you reminded me to mute this thread. I have tried VSCode on a few brand new installs of windows and it's the same thing on each one. Maybe in a year or two it will work. |
For future reference, some Windows terminal issues (including this Ctrl-C one) are not easily fixed. There is currently an effort to design a PTY API for Windows, but until that ships, we have to rely on hacks because the functionality just isn’t there in Windows yet. This is disappointing for me too. I don’t work for MS but I am participating in the API discussion because it’s something I’m passionate about seeing solved. Progress is being made, it’s just going to be a while. For reference: microsoft/terminal#57 |
By the way if you want to run python, you could press Ctrl-shift-p and "Python: Create Terminal", which let you create a terminal named "Python". Within this terminal Ctrl+c always works immediately. This could be a temporary solution for ones working with python. |
Just started seriously using VSCode on Windows after a year or so on Ubuntu. Looks like I'm stuck with Git Bash for my shell until they fix this? |
It's in progress. PTY support is enabled in skip ahead insider builds, it's just not exposed as a stable documented API yet so only usable through WSL interop, but it's working pretty well. You could actually have a better terminal at this point on skipahead builds by running the Linux VSCode in WSL and setting your shell to a Windows exe, which will go through a Linux PTY to an NT interop PTY. |
Ctrl+C is not configured for Windows, as it does not work (yet): microsoft/vscode#9347 microsoft/terminal#57
Ctrl+C is not configured for Windows, as it does not work (yet): microsoft/vscode#9347 microsoft/terminal#57
Ctrl+C is not configured for Windows, as it does not work (yet): microsoft/vscode#9347 microsoft/terminal#57
I'm not sure how to fix this or any workarounds... I'm on Windows (7 Pro 64-bit), latest VS Code, and using Git Bash shell in the Terminal tab with User Settings "terminal.integrated.shell.windows": "C:\Program Files\Git\bin\bash.exe", I also don't have a Break key on my laptop keyboard... and I'm right in the middle of a node session I need to restart. I can completely close the terminal but that's obnoxious. |
Find the node process, and type "kill -id <node pid>" in PowerShell, or if it's the only node running, "kill -name node". We technically have PTY support on insider builds now, but the API isn't official yet, so you'd have to make it open a WSL pty currently. |
I have same problem with git bash, but after press ctrl+c, if I wait like 5 minutes it will stop the "npm start" process for me. After this problem I start using regular windows console and it works well, now my system works much faster! which is another problem with integrated terminal! |
I find what was my problem. |
Ctrl+C is not configured for Windows, as it does not work (yet): microsoft/vscode#9347 microsoft/terminal#57
How quaint. |
Update on this: I'm currently working on conpty support which is expected to fix this for newer versions of Windows 10 microsoft/node-pty#216 |
Will this fix the external terminal as well? |
2 years lol |
It seems like the intent of Ctrl+C as "copy" is to maintain consistent behavior across the Editor and the Terminal areas in VS Code on Windows. Keeping that in mind, are there alternative commands that can be used in the Terminal to send an interrupt (SIGINT) to the running process? Can anyone (maybe @Tyriar) explain how to create a new keyboard shortcut (Edit > Preferences > Keyboard Shortcuts) binding that sends a POSIX-style Ctrl+C to the Terminal while allowing the Windows Ctrl+C to remain "copy"? |
For anyone else experiencing this in Powershell, as a workaround you can add the following key handler to your Set-PSReadLineKeyHandler -Key (0x03 -as [char]) -Function CancelLine This should fix the issue of not clearing a line on Ctrl+C while preserving default behaviour of copying text if it's already selected. This won't help with the original issue though (Ctrl+C in other contexts), but at least should help with the most common annoyance. |
ConPTY support is landing in the next Insiders build, this uses a new backend for the terminal on WIndows 10 build number 17692+, this is expected to fix many bugs in the terminal on Windows as we're adopting Microsoft's official pty API. For earlier versions winpty will still be used a many bugs will still remain (unless they're fixed in that project). If you find any issues with conpty please report them to https://github.com/Microsoft/console (the team who own ConPTY) or this repo (if you think it's an integration issue). You can opt out of conpty by adding this setting:
|
Steps to Reproduce:
In version 1.3.1 I noticed that ctrl-c does not work and prevents exiting the current command. In my case I configured terminal to open PowerShell.
Example:
The text was updated successfully, but these errors were encountered: