chrisbra / Colorizer

color hex codes and color names
549 stars 31 forks source link

:ColorToggle needs to run executed twice to turn colours off #59

Closed arp242 closed 6 years ago

arp242 commented 6 years ago

The issue seems related to the empty(w:match_list) check in Colorizer#ColorToggle() (see below). Calling Colorizer#ColorOff() directly works fine.

$ ls | vim -

Then in Vim enable colours; all good:

:packadd Colorizer
:ColorToggle

Note w:match_list is empty; after calling :ColorToggle the colours stay and nothing seems to happen? w:match_list is populated afterwards though:

:echo w:match_list
[]
:ColorToggle
:echo w:match_list
[{'group': 'Color_NONE_NONE', ... trimmed ... ]

Calling it a second time disabled colours and removes the w:match_list variable:

:ColorToggle
:echo w:match_list
E121: Undefined variable: w:match_list
E15: Invalid expression: w:match_list
chrisbra commented 6 years ago

Hm, https://github.com/chrisbra/Colorizer/blob/e6876f6f390de7039116efe348a754f121d8ce77/autoload/Colorizer.vim#L1682-L1687 this intentionally disabled storing the match result in the w:match_list variable. I do not remember why I did this, but I think this was, because when matchaddpo() was added to Vim, the result could not be used by setmach() or something like this. Well, let's just try to enable this and see if this causes any problems.

arp242 commented 6 years ago

Cheers, thanks!