microsoft / vscode

Visual Studio Code
https://code.visualstudio.com
MIT License
163.49k stars 28.98k forks source link

Launching External Terminal Changes Ctrl+C Handling Of Programs #205417

Open MikuAuahDark opened 8 months ago

MikuAuahDark commented 8 months ago

Type: Bug

Steps to reproduce:

  1. Launch VSCode (anywhere)
  2. Start new external terminal using Ctrl+Shift+C. I used Command Prompt in this case.
  3. Launch new program that can handle Ctrl+C
  4. Press Ctrl+C.

Expected result: Program handles Ctrl+C normally. Actual result: Program doesn't sees Ctrl+C at all.

A simple program that can handle Ctrl+C for this example is Python. However any app that handles Ctrl+C is affected (such as my simple WASAPI loopback program). Run this Python script within same terminal that VSCode creates at step 2.

try:
    while True:
        pass
except KeyboardInterrupt:
    print("OK")

If Ctrl+C is pressed while that script is running:

Reproducible both in insiders and stable (1.87.0).

VS Code version: Code - Insiders 1.88.0-insider (8c2b09c0443b94d75a73819ed35610f7e09375ae, 2024-02-28T18:53:20.095Z) OS version: Windows_NT x64 10.0.22631 Modes:

System Info |Item|Value| |---|---| |CPUs|AMD Ryzen 7 4700U with Radeon Graphics (8 x 1996)| |GPU Status|2d_canvas: enabled
canvas_oop_rasterization: enabled_on
direct_rendering_display_compositor: disabled_off_ok
gpu_compositing: enabled
multiple_raster_threads: enabled_on
opengl: enabled_on
rasterization: enabled
raw_draw: disabled_off_ok
skia_graphite: disabled_off
video_decode: enabled
video_encode: enabled
vulkan: disabled_off
webgl: enabled
webgl2: enabled
webgpu: enabled| |Load (avg)|undefined| |Memory (System)|15.39GB (7.43GB free)| |Process Argv|--crash-reporter-id ca2e3ed8-bdf1-4e2a-b9d7-b651fe0eba6b| |Screen Reader|no| |VM|0%|
Extensions: none
A/B Experiments ``` vsliv368cf:30146710 vspor879:30202332 vspor708:30202333 vspor363:30204092 vscod805cf:30301675 vsaa593cf:30376535 py29gd2263:30784851 c4g48928:30535728 962ge761:30841072 pythongtdpath:30726887 welcomedialog:30812478 pythonidxpt:30768918 pythonnoceb:30776497 asynctok:30898717 dsvsc013:30777762 dsvsc014:30777825 dsvsc015:30821418 pythontestfixt:30866404 pythonregdiag2:30926734 pyreplss1:30879911 pythonmypyd1:30859725 pythoncet0:30859736 pythontbext0:30879054 accentitlementst:30870582 dsvsc016:30879898 dsvsc017:30880771 dsvsc018:30880772 cppperfcontrol:30963551 d34g3935:30961436 edj9j583:30943796 fegfb526:30952798 7j2b6412:30951517 bg6jg535:30946824 ccp1r3:30958150 ```
kevingjs commented 7 months ago

+1

mstv commented 7 months ago

It does not matter whether the external terminal is opened using a hotkey or using the command palette. The internal terminal is not affected, i.e. Ctrl+C works there.

haezera commented 5 months ago

+1

Please fix this issue/provide us a solution. It used to work completely fine last year, have zero clue what happened.

MikuAuahDark commented 5 months ago

A workaround that works for me is to run wt && exit after VSCode launches the external terminal. The new Windows Terminal tab will not have the issue. Unfortunately this only works if users set Windows Terminal as their default conhost.