microsoft / vscode

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

Integrated terminal automatically sends 'Y' when terminating node batch script #142341

Closed stephenmatheis closed 2 years ago

stephenmatheis commented 2 years ago

Thank you so much for looking into this 🙏 !

Issue Type: Bug

~ > npm run concurrently \"script-1.js\" \"script-2.js\"
~ > [ type >> ctrl + c]
~ > Terminate batch job (Y/N)? Y (this character is automatically sent, but only terminates first script, putting remaining output in prompt on next line)
~ > [0] node script-name
~ > [type >> enter]
~ >                                                   y (character is still present, with spaces prepended)
~ > y : The term 'y' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name,   
or if a path was included, verify that the path is correct and try again.
At line:1 char:1

VS Code version: Code 1.64.0 (5554b12acf27056905806867f251c859323ff7e9, 2022-02-03T04:22:20.678Z) OS version: Windows_NT x64 10.0.19044 Restricted Mode: No

System Info |Item|Value| |---|---| |CPUs|AMD Ryzen 9 3900X 12-Core Processor (24 x 3793)| |GPU Status|2d_canvas: enabled
gpu_compositing: enabled
multiple_raster_threads: enabled_on
oop_rasterization: enabled
opengl: enabled_on
rasterization: enabled
skia_renderer: enabled_on
video_decode: enabled
vulkan: disabled_off
webgl: enabled
webgl2: enabled| |Load (avg)|undefined| |Memory (System)|31.93GB (22.74GB free)| |Process Argv|C:\\Users\\steph\\OneDrive\\Documents\\GitHub\\robi --crash-reporter-id bc47a489-a287-44e8-9f71-a241e2b29255| |Screen Reader|no| |VM|0%|
Extensions (10) Extension|Author (truncated)|Version ---|---|--- es6-string-css|bas|0.1.0 python|ms-|2022.0.1786462952 vscode-pylance|ms-|2022.2.0 jupyter|ms-|2022.1.1001775990 remote-wsl|ms-|0.64.2 powershell|ms-|2021.12.0 LiveServer|rit|5.7.4 es6-string-html|Tob|2.12.0 vscode-todo-highlight|way|1.0.5 es6-string-javascript|zjc|1.0.1
A/B Experiments ``` vsliv368cf:30146710 vsreu685:30147344 python383:30185418 vspor879:30202332 vspor708:30202333 vspor363:30204092 pythonvspyl392cf:30425750 pythontb:30283811 pythonptprofiler:30281270 vshan820:30294714 vstes263cf:30335440 pythondataviewer:30285071 vscod805:30301674 pythonvspyt200:30340761 binariesv615:30325510 bridge0708:30335490 bridge0723:30353136 vsaa593cf:30376535 vsc1dst:30433059 pythonvs932:30410667 wslgetstartedc:30433508 vscop940:30404999 vsrem710:30416614 vscop841:30430977 ```
meganrogge commented 2 years ago

You can fix this by setting the value of terminate hatch job within terminal.integrated.autoReplies to null

stephenmatheis commented 2 years ago

@meganrogge, Thank you so much! I should have checked if this was a setting first. Just curious - is this a new setting/behavior? Just started happening with 1.64.

Snailedlt commented 2 years ago

This is still a bug.

This happens for me too. Every time I type CTRL+C it autoresponds Y. Now every time I type anything in the terminal after this, it writes Y after it: image

Y : The term 'Y' is not recognized as the name of a cmdlet, function, script file, or operable progr
am. Check the spelling of the name, or if a path was included, verify that the path is correct and t 
ry again.
At line:1 char:1
+ Y
+ ~
    + CategoryInfo          : ObjectNotFound: (Y:String) [], CommandNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException

If I type any command that gives a prompt, it stops autoresponding with Y. It also seems that writing git commands in the terminal somehow stops the Yautoresponse.

Edit: Like like @meganrogge mentioned, adding

"terminal.integrated.autoReplies": {
    "Terminate batch job (Y/N)": null
  }

to settings.json will prevent this from happening. Note that this is just a workaround, since it does not fix the actual issue of Y being responded to any message, but rather disables the autoresponse alltogether

Tyriar commented 2 years ago

I bet this is conpty reprinting causing duplicate responses 🤦

Tyriar commented 2 years ago

Updating to Windows 11 might workaround this as I've never hit this issue. The theory is that something running in the terminal is triggering conpty (the backend component) to reprint the screen which would re-output the match text.

Tyriar commented 2 years ago

Thanks for the report, I'm going to disable it by default to be safe. We also had an idea for later on to allow the feature to be discovered intuitively when the user responds manually.

How to configure for the batch job message is now called out in the docs:

image

filiptronicek commented 2 years ago

meganrogge, Thank you so much! I should have checked if this was a setting first. Just curious - is this a new setting/behavior? Just started happening with 1.64.

This indeed is new with 1.64, see the release notes for details.

bballweiss commented 2 years ago

I'm trying to use this to automatically enter Y when terminating a batch job. It is giving me an error after my next command though, because it enters "Y" again. This is what I have in settings.json: image

And this is my terminal: image

I saw Windows 11 was mentioned above. Do I need to be on that in order to use this feature?

Tyriar commented 2 years ago

Yes on older versions of Windows this is less reliable as the terminal emulation provided by Windows ends up reprinting the screen, causing the phrase to show up again.

Snailedlt commented 2 years ago

Shouldn't this be fixed for Windows 10 too though? It's still supported by Microsoft and VSCode, right?

Regenhardt commented 2 years ago

So is the conclusion just "Not supported you gotta disable it on Windows 10 yourself" and case closed? Doesn't seem right.

Regenhardt commented 2 years ago

Ok I see you disabled it by default in a merge request. So the state is now "this isn't supported on Windows 10"?

How about this:

Currently it seems to go "if (buffer.Contains(trigger)) send(reply);"
So what if instead it goes "if (buffer.Contains(trigger) && !buffer.Contains(trigger+reply)) send(reply);"

You know, just check if the line that was found already has a reply?

bballweiss commented 2 years ago

Thanks for the reply. I don't think it is OK to leave it as is. I saw it in the release notes (https://code.visualstudio.com/updates/v1_64#_automatic-replies) and spent way too much time trying to get it to work before finding this thread. Can it either be fixed to work with Windows 10 or update the docs to make it clear that Windows 11 is needed?