neoclide / coc-highlight

Document highlight and document colors LSP support for coc.nvim
221 stars 12 forks source link

Do not highlight HTML entities #18

Closed kkoomen closed 4 years ago

kkoomen commented 5 years ago

The current highlighting for colors should not highlight the color when prefixed with the & character. I suggest to add a look-around here by optimizing the regex to:

const colorHex = /(?<=\W|&|^)((?:#)([a-f0-9]{6}([a-f0-9]{2})?|[a-f0-9]{3}([a-f0-9]{1})?))\b/gi

(The above adds & to (?<=\W|^)). See regex101 for working demo.

Screenshot

Screenshot 2019-08-14 at 16 18 56
kkoomen commented 4 years ago

@chemzqm Can you merge this?

chemzqm commented 4 years ago

It doesn't fix the highlight.

kkoomen commented 4 years ago

@chemzqm Sorry, you should use this regex (demo):

const colorHex = /(?<!&|\w)((?:#)([a-f0-9]{6}([a-f0-9]{2})?|[a-f0-9]{3}([a-f0-9]{1})?))\b/;

I thought it already used negative-look-behind, but it didn't, so I used that. Makes more sense in this case.

kkoomen commented 4 years ago

@chemzqm Can you merge?