llvm / llvm-project

The LLVM Project is a collection of modular and reusable compiler and toolchain technologies.
http://llvm.org
Other
28.27k stars 11.68k forks source link

[clang][Diagnostics] Highlighted code snippets render diagnostics unusable #82945

Open nabijaczleweli opened 7 months ago

nabijaczleweli commented 7 months ago

I just got this:

How do I make it not be that? I see no tunable to disable this in 718aac9f7a19227b5c5ec85819a3a5ae24ce32e1 and the thread under #66514 would imply there is, by design, no way! it suggests -fno-color-diagnostics which yields which is also wrong.

How does one get normal, usable, diagnostics with normally-copied, usable, inlined code? Even if you would, for some reason, want this to be the default, why is there seemingly no way to disable this? Why was this not a question anyone asked before?

tbaederr commented 7 months ago

Clang does not pick an RGB value here, it just select "blue". If the blue your terminal chooses isn't readable on the background it chooses, that's a bad choice. You should configure your terminal to select a readable version of blue.

We've tested the currently chosen colors in the default color themes of common terminals and they looked all readable.

hazohelet commented 7 months ago

image

+1 to having a flag to disable syntax-highlighting. When using godbolt with Dark theme the blue highlight is hard to read for my eyes (that aren't good at distinguishing certain colors than others do). I've been happily using Light theme there for weeks now, but it would be helpful to have a way to disable the syntax highlighting. Or, would it be acceptable to use cyan for the keywords like gcc does? It would fix this problem for many people, I think.

tbaederr commented 7 months ago

The "blue" on godbolt.org has already been fixed for us (that's why it works), I guess the dark theme was missed. CC @Endilll

Or, would it be acceptable to use cyan for the keywords like gcc does?

What makes you think cyan is always readable? It has the exact same problem. (side note: the red above isn't exactly readable either).

I really don't want every terminal in the world to change for clang, but let's put the blame where it it belongs.

nabijaczleweli commented 7 months ago

Sorry, in what world is "actually this is your fault for selecting a colour I don't like. make it be one i like." a remotely-valid response here? Even if you magically matched my preferred theme, using any colour at all is invalid, both to me and to many other users. Simple as. Just because you like the code to be copied with markup so much you want to show it to me as well does not mean I will some-how no longer despise it.

If you want this to be on-by-default, for some bizarre reason, then it needs to be trivially globally-disableable. Hell, make it take CLANG_HIGHLIGHT=off (or even CLANG_HIGHLIGHT=comment=red;keyword=blue;type=pink or whatever), I'd set that shit and forget it. How could that not be part of the original design‽

Endilll commented 7 months ago

When using godbolt with Dark theme the blue highlight is hard to read for my eyes (that aren't good at distinguishing certain colors than others do).

@hazohelet You're free to chime in: https://github.com/compiler-explorer/compiler-explorer/pull/5848. I contacted CE devs a month ago there and on Discord, so this shouldn't be news for them.

Sorry, in what world is "actually this is your fault for selecting a colour I don't like. make it be one i like." a remotely-valid response here?

@nabijaczleweli The fact is that we don't have control over rendering of ANSI colors in terminals. Simple as that. And I don't think anyone said you're at fault here. Your terminal is, though.

Even if you magically matched my preferred theme, using any colour at all is invalid, both to me and to many other users.

Clang and GCC have been highlighting error, warning, and note for years. Is this also invalid now?

CLANG_HIGHLIGHT=off (or even CLANG_HIGHLIGHT=comment=red;keyword=blue;type=pink or whatever)

Patches are welcome.

As for the rest of your message, I'd like you to be mindful of LLVM Code of Conduct.

hazohelet commented 7 months ago

I really don't want every terminal in the world to change for clang, but let's put the blame where it it belongs.

I see. The only problem for me was with the Dark theme in CE. Learning there's a patch to fix it on CE side, I now have no reason to object to the direction.

You're free to chime in: compiler-explorer/compiler-explorer#5848. I contacted CE devs a month ago there and on Discord, so this shouldn't be news for them.

@Endilll Thanks for letting me know! I'll keep an eye on those threads.