enyancc / vscode-ext-color-highlight

Extension adds colored border around css/web colors in the editor
GNU General Public License v3.0
262 stars 83 forks source link

Ignore `0xHHH` and `0xHHHH` hex colors #143

Open thomcc opened 3 years ago

thomcc commented 3 years ago

I've genuinely never seen the 3 and 4 character 0x-prefixed version used to represent a color (and have worked with colors represented as integers a lot). It feels like it was included just because # supports them (which is good — that is much more common).

IMO, as it is it triggers far too often. Stuff like x = n & 0xffff and the like, which is bordering on silly.

ferretwithaberet commented 3 years ago

Instead of outright removing them. Would you mind making this a setting? In my opinion this solution would make everyone happy.

thomcc commented 3 years ago

Instead of outright removing them. Would you mind making this a setting? In my opinion this solution would make everyone happy.

Sure, but is there anybody who actually uses it that way? I'd be surprised.

I don't mind making it a setting though.

ferretwithaberet commented 3 years ago

Instead of outright removing them. Would you mind making this a setting? In my opinion this solution would make everyone happy.

Sure, but is there anybody who actually uses it that way? I'd be surprised.

I don't mind making it a setting though.

I cannot know as we do not collect any data on how the extension is used. But like you said

It feels like it was included just because # supports them (which is good — that is much more common).

If # syntax supports it, it means that it has use cases, so it should be supported. Some people might actually use it, I think I even used it for white/black (#fff or #000) because it is easier to write.

ferdnyc commented 10 months ago

@ferretwithaberet

It feels like it was included just because # supports them (which is good — that is much more common).

If # syntax supports it, it means that it has use cases, so it should be supported. Some people might actually use it, I think I even used it for white/black (#fff or #000) because it is easier to write.

See, that's the one part of this argument that doesn't make sense to me. Just because #rgb and #rgba are supported by the CSS parser as shorthands (and nobody has ever been suggesting that support for those patterns be removed), that doesn't mean that 0xrgb and 0xrgba are ever used in code to store color values.

I guarantee that CSS parser implementations that read an #rgb string store that value in-memory as 0xrrggbb (or even 0xrrggbbFF), as nobody in their right mind would pack the color value of 0xrrggbb into 0xrgb — that's an optimization for humans, not for code.