Skip to content

Integrated Terminal: ctrl-c doesn't work in PowerShell and cmd.exe #9347

Closed

Description

@Chiliyago
  • VSCode Version: 1.31
  • OS Version: Windows

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:

PS: >mkdir
cmdlet mkdir at command pipeline position 1
Supply values for the following parameters:
Path[0]:  <<ctrl-c should exit but it does not work>>

Activity

  1. added
    feature-request
    terminal
    and removed
    feature-request
    on Jul 15, 2016
  2. Tyriar commented on Jul 15, 2016

    @Tyriar
    Contributor
  3. added
    info-needed
    windows
    on Jul 15, 2016
  4. added this to the Backlog milestone on Jul 15, 2016
  5. daviwil commented on Jul 16, 2016

    @daviwil
    Contributor

    I haven't tried it in previous builds so I'm not sure whether it ever worked.

  6. gerane commented on Jul 17, 2016

    @gerane

    Yeah, it's never worked for me.

  7. added
    feature-request
    and removed
    info-needed
    on Jul 17, 2016
  8. jmreicha commented on Jan 1, 2017

    @jmreicha

    Any update on this?

  9. gerane commented on Jan 1, 2017

    @gerane

    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 David Wilson (@daviwil) Daniel Imms (@Tyriar) and a few others about it last week, but then I started to get sick.

  10. midnightfreddie commented on Jan 6, 2017

    @midnightfreddie

    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.

  11. 28 remaining items

  12. gearskullguy commented on Jun 6, 2018

    @gearskullguy

    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.

  13. parkovski commented on Jun 6, 2018

    @parkovski

    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.

  14. saostad commented on Aug 10, 2018

    @saostad

    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.
    I am using create-react-app typescript package
    but if I use "docker-compose up" to run my docker container after I press ctrl+c it stop the container without problem.

    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!

  15. saostad commented on Aug 13, 2018

    @saostad

    I find what was my problem.
    for some reason I had this in my settings:
    "terminal.integrated.rendererType": "dom"
    after I remove it it start working and it's much faster

  16. simeyla commented on Aug 23, 2018

    @simeyla

    How quaint.
    I remember the first time I used Ctrl+C.
    It was 22 years ago. I'm pretty sure it worked every time :-/

  17. Tyriar commented on Aug 23, 2018

    @Tyriar
    Contributor

    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

  18. oliverjanik commented on Sep 6, 2018

    @oliverjanik

    Will this fix the external terminal as well?

  19. shinebayar-g commented on Nov 2, 2018

    @shinebayar-g

    2 years lol

  20. openm commented on Dec 15, 2018

    @openm

    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 Daniel Imms (@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"?

  21. RReverser commented on Dec 21, 2018

    @RReverser
    Contributor

    For anyone else experiencing this in Powershell, as a workaround you can add the following key handler to your $PROFILE:

    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.

  22. Tyriar commented on Dec 21, 2018

    @Tyriar
    Contributor

    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:

    "terminal.integrated.windowsEnableConpty": false
    
  23. locked as resolved and limited conversation to collaborators on Dec 21, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

help wantedterminalupstreamwindows

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions