Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
hyp0xia opened this issue Oct 2, 2015 · 13 comments
Open

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

hyp0xia opened this issue Oct 2, 2015 · 13 comments

Comments

@hyp0xia
Copy link

hyp0xia commented Oct 2, 2015

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?

@miguelolivares
Copy link

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

@jbrooksuk
Copy link
Collaborator

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?

@hyp0xia
Copy link
Author

hyp0xia commented Oct 28, 2015

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.

@miguelolivares
Copy link

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
Copy link

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

@jbrooksuk
Copy link
Collaborator

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

@nbonamy
Copy link

nbonamy commented Apr 10, 2016

Probably a colon is missing here but cannot figure where!

@digeomel
Copy link
Contributor

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
Copy link
Contributor

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

@digeomel
Copy link
Contributor

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
Copy link
Contributor

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 😄

digeomel added a commit to digeomel/GutterColor that referenced this issue Jul 29, 2016
digeomel added a commit to digeomel/GutterColor that referenced this issue Jul 29, 2016
jbrooksuk added a commit that referenced this issue Jul 29, 2016
Fixes issue #93 [Lots of random "red dots" showing up in the gutter]
@sAs59
Copy link

sAs59 commented May 27, 2017

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

@glennabaron
Copy link

glennabaron commented Jan 30, 2018

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 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants