Every time vscode runs C++ code, the terminal will enter a ^C instruction and an Enter operation before it starts.
PS D:DocumentsCodeSTL> ^C
PS D:DocumentsCodeSTL>
PS D:DocumentsCodeSTL> & 'c:Users27532.vscodeextensionsms-vscode.cpptools-1.19.9-win32-x64debugAdaptersbinWindowsDebugLauncher.exe' '--stdin=Microsoft-MIEngine-In-ycqe3hxg.xjn' '--stdout=Microsoft-MIEngine-Out-c1vkgva4.men' '--stderr=Microsoft-MIEngine-Error-qsdbie2i.1u5' '--pid=Microsoft-MIEngine-Pid-wpjz1cze.2ye' '--dbgExe=d:DevEnvMSYS2ucrt64bingdb.exe' '--interpreter=mi'
I swear this action was not entered by me
I checked launch.json
file contents and there was no problem
C/C++ extend is v1.19.9
- launch.json
{
"configurations": [
{
"name": "C/C++: g++.exe 生成和调试活动文件",
"type": "cppdbg",
"request": "launch",
"program": "${workspaceFolder}\out\${fileBasenameNoExtension}.exe",
"args": [],
"stopAtEntry": false,
"cwd": "d:\DevEnv\MSYS2\ucrt64\bin",
"environment": [],
"externalConsole": false,
"MIMode": "gdb",
"miDebuggerPath": "d:\DevEnv\MSYS2\ucrt64\bin\gdb.exe",
"setupCommands": [
{
"description": "为 gdb 启用整齐打印",
"text": "-enable-pretty-printing",
"ignoreFailures": true
},
{
"description": "将反汇编风格设置为 Intel",
"text": "-gdb-set disassembly-flavor intel",
"ignoreFailures": true
}
],
"preLaunchTask": "C/C++: g++.exe 生成活动文件"
}
],
"version": "2.0.0"
}
0
Considering the timing of this question (posted right after the release of VS Code 1.88), this is likely the result of pull request debug: clear prompt if a terminal is reused betwen debug sessions #206632, which was made in response to issue ticket My project’s root directory got deleted during the execution of Python Debugging Session. #106743, and put in the March 2024 (1.88) release milestone.
I encourage you to read those linked resources to understand the context, but TL;DR is there was a paper-cut scenario (mixed with some rather bad luck) where debug configurations that reuse the terminal created for prior runs wouldn’t do anything to clear any non-executed/in-progress commandline if the user wrote something in the commandline for that terminal, but didn’t execute it, and then ran the same debug configuration again.
This change is supposed to tell the shell to abort editing the current command and start a new one (it seems to happen that most shells use ctrl+c
/ u0003
(ASCII end-of-text) for this).
At the time of this writing, there’s no way to configure whether or not VS Code does this.
If this actually causes issues for you, you should raise an issue ticket about it, making sure to explain what the issue is, and linking back to #206632 and #106743 for historical context.
Fun fact- some shells have mechanisms to not print / echo back “^C” when such a signal is sent to the shell. For example, for Bash, see Prevent “^C” from being printed when aborting editing current prompt (stty -ctlecho
). But I’d suggest you think carefully before you do that- it could lead to future confusion for yourself if you forget that you did that.
Meta answer
A walkthrough of how I figured this out, in case you want to learn how to do it yourself in the future (it’s fun!).
- Open https://github.dev/microsoft/vscode
- Go to the Search View
- Put “*.ts” in the “Files to Include” field, and “test.ts,test.js” in the “Files to Exclude” field
- (I later adjust the exclude to “test.ts,test.js,extensions/,notebook“) since this seems to have nothing to do with notebooks, and from another similar question that I saw posted near the same time as this question post, this behaviour seems related to VS Code’s core debug functionality, and not to be extension-specific.
- Try related searches like “^C” (make sure to turn regex search mode off, or escape the
^
), “ctrl+c” (keep case-sensitive mode off), etc. Look out for any files that are related to debug or the terminal. - A couple lines caught my attention:
- https://github.com/microsoft/vscode/blob/bb7bd51f30e402695e609a080a82c1eca01a729c/src/vscode-dts/vscode.proposed.terminalShellIntegration.d.ts#L86 (but I ruled this out since it pertains to a proposed API which is not yet finalized, so the Microsoft C/C++ and Python extensions wouldn’t be able to use them in their stable releases)
- https://github.com/microsoft/vscode/blob/bb7bd51f30e402695e609a080a82c1eca01a729c/src/vs/workbench/contrib/terminal/browser/terminalInstance.ts#L845
- https://github.com/microsoft/vscode/blob/bb7bd51f30e402695e609a080a82c1eca01a729c/src/vs/workbench/api/node/extHostDebugService.ts#L131
- For those last two, right click those lines in the gutter to copy a GitHub head link, open the links, switch to the Git Blame view, and see if those lines have been modified recently.
- Click into any recent pull requests, and read about their linked issue tickets.
- Profit.
0