GutterColor icon indicating copy to clipboard operation
GutterColor copied to clipboard

Lots of random "red dots" showing up in the gutter.

Open hyp0xia opened this issue 9 years ago • 13 comments

Noticed recently that there are a lot of red color circles showing up in my gutter where there is no red color defined in the adjacent line of code. Even happens on blank lines for that matter.

Any ideas?

hyp0xia avatar Oct 02 '15 16:10 hyp0xia

It happens because the "red" word inside "featured". Red is a color.

miguelolivares avatar Oct 26 '15 20:10 miguelolivares

It happens because the "red" word inside "featured". Red is a color.

I don't think that's true, the regex shouldn't be picking that up?

jbrooksuk avatar Oct 27 '15 07:10 jbrooksuk

Yeah I don't think it's true either. That logic doesn't explain why they are showing up on brackets, white, white space, and comment lines, etc.

hyp0xia avatar Oct 28 '15 23:10 hyp0xia

Look at this: Any css color name (http://www.w3schools.com/cssref/css_colornames.asp) used in any part of a CSS document is taken as a color declaration.

screen shot 2015-10-29 at 0 32 39

miguelolivares avatar Oct 29 '15 03:10 miguelolivares

My bad. I didn't see the red dot in empty lines.

miguelolivares avatar Oct 29 '15 03:10 miguelolivares

That'll be the web colors highlighting. https://github.com/ggordan/GutterColor/blob/master/line.py#L207

jbrooksuk avatar Oct 29 '15 08:10 jbrooksuk

Probably a colon is missing here but cannot figure where!

nbonamy avatar Apr 10 '16 07:04 nbonamy

I get the same. And it's not only red, it's seemingly random (or false) colours everywhere. There's obviously something wrong with the regex used (assuming it's a regex). screenshot from 2016-07-29 15-34-32

digeomel avatar Jul 29 '16 13:07 digeomel

Hah, and to answer my own comment, it seem to pick up the "tan" colour from "important" :smile:

digeomel avatar Jul 29 '16 13:07 digeomel

Ok, this seems to work for me (from line.py, lines 204-214):

def generate_webcolors(self):
"""Generates a list of web color names."""
self.WEB_COLORS = dict((name, color) for (name, color) in css3_names_to_hex.items())
self.WEB_COLORS_REGEX = '\\s(' + '|'.join(self.WEB_COLORS.keys()) + ')[\\s;]'
# self.WEB_COLORS_REGEX = '((?<!\$)'+ '|(?<!\$)'.join(self.WEB_COLORS.keys()) +')'

def web_color(self):
"""Returns the color in the line, if any CSS color name is found."""
matches = re.search(self.WEB_COLORS_REGEX, self.text)
if matches:
  return matches.group(1)

Note that because the regular expression is changed to match blank characters at the start and end of the named colour, you have to change line 214 as well to read matches.group(1) instead of matches.group(0)

digeomel avatar Jul 29 '16 14:07 digeomel

In retrospect the regex can be improved a little bit more like this:

self.WEB_COLORS_REGEX = '[\\s:](' + '|'.join(self.WEB_COLORS.keys()) + ')[\\s;]'

But by now you get the point :smile:

digeomel avatar Jul 29 '16 14:07 digeomel

@digeomel it doesn't work without semicolon. In *.sass for example

sAs59 avatar May 27 '17 18:05 sAs59

Its been a minute, and its kind of hacky, but in case this helps anyone else: If you try to stay away from using color names (and mainly use HEX or RGBA, etc.), just remove the list of web safe colors 👍

glennabaron avatar Jan 30 '18 20:01 glennabaron