GutterColor icon indicating copy to clipboard operation
GutterColor copied to clipboard

css id selector that start with valid hex char are interpreted as color

Open megatrond opened this issue 11 years ago • 6 comments

screen shot 2014-03-21 at 13 52 40

Or at least the plugin gets confused. Possibly check for the presence of a colon and semicolon on the same line?

megatrond avatar Mar 21 '14 12:03 megatrond

Ok good, there is an issue already opened on this. I experienced this yesterday but posted it in the wrong spot.

mordof avatar Mar 22 '14 20:03 mordof

I think I just added (.*); at the end of the hex regex and it seemed like it was fixed.

megatrond avatar Mar 22 '14 21:03 megatrond

Ah, I see what you mean. That's not a good way to handle that though.

a) you're adding another capture group. b) that capture group will match everything all the way up until the last semi-colon in the line. c) this will still match something like this: #facebookPageLink { color: #ffffff; } as #fac instead of #ffffff

That's not to say i think people would normally run into the issue of item c. however I think this might be a better approach:

'#((?:[0-9a-fA-F]{3}){1,2})(?!.*{)'

Adding a negative lookahead to check for a { instead.

Confirmed that it works - but I don't know a whole lot about performance - i have a feeling it's possible this might be slower than it needs to be.

With that said, I tested it not only with #nav #back { // rules on the next line, and it removes the item... but I also tested it with #afc { color: #ff0000; } and it shows up as a red circle. where as with your regex modification, the circle would still reflect #afc.

mordof avatar Mar 22 '14 22:03 mordof

Now to figure out how to submit that change... I'd like to start contributing in other areas to this plugin as well. hmmm..

mordof avatar Mar 22 '14 22:03 mordof

@mordof are you still interested in contributing that change?

jbrooksuk avatar Jul 10 '14 18:07 jbrooksuk

@jbrooksuk Ah! Thanks for the reminder! I had gotten busy with other stuff and completely forgot. I'd like to, but I didn't find out how... I'll give it another try today.

mordof avatar Jul 11 '14 00:07 mordof