GutterColor
GutterColor copied to clipboard
Lots of random "red dots" showing up in the gutter.
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?
It happens because the "red" word inside "featured". Red is a color.
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?
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.
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.
My bad. I didn't see the red dot in empty lines.
That'll be the web colors highlighting. https://github.com/ggordan/GutterColor/blob/master/line.py#L207
Probably a colon is missing here but cannot figure where!
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).
Hah, and to answer my own comment, it seem to pick up the "tan" colour from "important" :smile:
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)
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 it doesn't work without semicolon. In *.sass for example
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 👍