Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No colors in task terminal with clang #9643

Closed
skarasov opened this issue Jul 26, 2022 · 5 comments
Closed

No colors in task terminal with clang #9643

skarasov opened this issue Jul 26, 2022 · 5 comments
Assignees
Labels
fixed Check the Milestone for the release in which the fix is or will be available. Language Service tasks/build/debug An issue relating to tasks.json (e.g. build issues)
Milestone

Comments

@skarasov
Copy link

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.
b

refer:
microsoft/vscode#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

@sean-mcmanus
Copy link
Collaborator

The issue doesn't repro for me. What task type are you using in your task.json? Are you using arg " -fdiagnostics-color=always"?

@sean-mcmanus sean-mcmanus self-assigned this Jul 26, 2022
@sean-mcmanus sean-mcmanus added Language Service more info needed The issue report is not actionable in its current state tasks/build/debug An issue relating to tasks.json (e.g. build issues) not reproing We're not able to reproduce the issue (it's unlikely to get fixed until we find one). labels Jul 26, 2022
@skarasov
Copy link
Author

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\""
		}
	]
}

@Colengms
Copy link
Collaborator

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.

@Colengms Colengms changed the title No colors in task terminal No colors in task terminal with clang Jul 27, 2022
@Colengms Colengms removed more info needed The issue report is not actionable in its current state not reproing We're not able to reproduce the issue (it's unlikely to get fixed until we find one). labels Jul 27, 2022
@Colengms Colengms assigned Colengms and unassigned sean-mcmanus Jul 27, 2022
@Colengms Colengms added this to the 1.12 milestone Jul 27, 2022
@sean-mcmanus sean-mcmanus modified the milestones: 1.12, 1.12.1 Jul 28, 2022
@skarasov
Copy link
Author

                "-fcolor-diagnostics",
                "-fansi-escape-codes",

works for me, Thanks!

@Colengms Colengms added the fixed Check the Milestone for the release in which the fix is or will be available. label Aug 1, 2022
@sean-mcmanus
Copy link
Collaborator

@github-actions github-actions bot locked and limited conversation to collaborators Oct 15, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
fixed Check the Milestone for the release in which the fix is or will be available. Language Service tasks/build/debug An issue relating to tasks.json (e.g. build issues)
Projects
None yet
Development

No branches or pull requests

3 participants