vscode-cpptools
vscode-cpptools copied to clipboard
No colors in task terminal with clang
Issue Type: Bug
Simple c code.
Run build task with clang or cl.
In task terminal no colored output, but in ordinary terminal all fine.
refer: https://github.com/microsoft/vscode/issues/155444
Extension version: 1.11.4 VS Code version: Code 1.69.2 (3b889b090b5ad5793f524b5d1d39fda662b96a2a, 2022-07-18T16:12:52.460Z) OS version: Windows_NT x64 10.0.19044 Restricted Mode: No
The issue doesn't repro for me. What task type are you using in your task.json? Are you using arg " -fdiagnostics-color=always"?
No color only with clang.exe and cl.exe. With gcc.exe all fine.
task.json:
{
"version": "2.0.0",
"tasks": [
{
"type": "cppbuild",
"label": "C/C++: clang.exe build active file",
"command": "C:\\Program Files\\LLVM\\bin\\clang.exe",
"args": [
"-fdiagnostics-color=always",
"-g",
"${file}",
"-o",
"${fileDirname}\\${fileBasenameNoExtension}.exe"
],
"options": {
"cwd": "${fileDirname}"
},
"problemMatcher": [
"$gcc"
],
"group": {
"isDefault": true,
"kind": "build"
},
"detail": "compiler: \"C:\\Program Files\\LLVM\\bin\\clang.exe\""
}
]
}
Hi @skarasov .
The root of this problem has to do with how gcc and clang detect whether or not they are running within a shell terminal. If they detect they are in a shell terminal, they enable colorization. We could consider it a VS Code bug that the terminal used for tasks does not look like a shell terminal to them. I suspect it has something to do with how VS Code is redirecting and scanning the output of the task, circumventing the compiler's check. We can work around this issue with gcc by forcing colorization to be enabled using -fdiagnostics-color=always
.
After some experimentation, it looks like we can convince clang to also enable colorization using:
"-fcolor-diagnostics",
"-fansi-escape-codes",
We can use this issue to track adding these args to a task when the compiler used appears to be clang, instead of -fdiagnostics-color=always
.
"-fcolor-diagnostics",
"-fansi-escape-codes",
works for me, Thanks!
Fixed with https://github.com/microsoft/vscode-cpptools/releases/tag/v1.12.1 .