Closed alk0 closed 2 years ago
Thanks for reporting! A couple of questions:
I'll be honest, I personally never use the palettes. It was a feature I added back in the early days, but still carry around as some people I think do use it. With that said, I do usually test it anytime I feel like the code potentially could impact it.
I did test this locally when triaging this bug. I could not reproduce any issues. I deleted my local palette file to test if there was maybe an unknown issue with using ColorHelper for the first time, it seems to work:
- When you installed ColorHelper, did you restart Sublime Text afterward? If not, can you try it?
Yes, I did. Several times. Just restarted one more time - no effect.
- If the problem is persisting, can you look at the console and see if there are any errors being reported?
Ah, and now we are getting something!
Traceback (most recent call last):
File "/home/user/.config/sublime-text-3/Installed Packages/ColorHelper.sublime-package/ch_panel.py", line 54, in on_navigate
File "/home/user/.config/sublime-text-3/Installed Packages/ColorHelper.sublime-package/ch_panel.py", line 579, in show_palettes
File "/home/user/.config/sublime-text-3/Installed Packages/ColorHelper.sublime-package/ch_util.py", line 392, in get_project_palettes
File "/home/user/.config/sublime-text-3/Installed Packages/ColorHelper.sublime-package/ch_util.py", line 331, in _get_palettes
TypeError: sequence item 0: expected str instance, int found
What else can I do from here?
Interesting. Can you navigate to your Packages/User
folder and see if there is a color_helper.palettes
file and post its content here?
Also, did you have ColorHelper installed at one point in the past and possibly had an older palette file (with or without knowing), and possibly it didn't upgrade correctly?
{
"__format__": "2.0",
"favorites":
[
"color(srgb 0.34509803921568626972060656044050119817256927490234375 0.78039215686274510108688673426513560116291046142578125 0.45098039215686275271721683566283900290727615356445312)",
"color(srgb 0.60784313725490191071543222278705798089504241943359375 0.886274509803921528572345778229646384716033935546875 0.9568627450980391468959851408726535737514495849609375)",
"color(srgb 0.96470588235294119083818031867849640548229217529296875 0.79607843137254896692667216484551317989826202392578125 0.66666666666666662965923251249478198587894439697265625)",
"color(srgb 0.85098039215686271941052609690814279019832611083984375 0.862745098039215729812667632359080016613006591796875 0.48235294117647059541909015933924820274114608764648438)",
"color(srgb 0.90196078431372550543443367132567800581455230712890625 0.78431372549019606754683309191022999584674835205078125 0.9490196078431372139760924255824647843837738037109375)",
"color(srgb 0.53725490196078429239179286014405079185962677001953125 0.9254901960784314152164142797118984162807464599609375 0.77647058823529413462694037662004120647907257080078125)",
"color(srgb 0.96862745098039215729812667632359080016613006591796875 0.77647058823529413462694037662004120647907257080078125 0.79607843137254896692667216484551317989826202392578125)",
"color(srgb 0.60784313725490191071543222278705798089504241943359375 0.92156862745098033773416545955114997923374176025390625 0.64705882352941179735950072426931001245975494384765625)",
],
"palettes":
[
],
}
Also, did you have ColorHelper installed at one point in the past and possibly had an older palette file (with or without knowing), and possibly it didn't upgrade correctly?
I can't really tell for sure, it is not very probable, but I cannot exclude it. I used to try different plugins to find what I needed, maybe some old Color Helper happened to occur among them. Hard to tell now with 100% certainty.
Addition: I don't think it's relevant, but here's my current User/color-helper.sublime-settings
:
// Settings in here override those in "ColorHelper/color_helper.sublime-settings",
{
"enabled_color_picker_modes": ["srgb", "hsl", "hsv", "okhsl"],
}
Your settings seem to look fine. My newly created, working palette file:
{
"__format__": "2.0",
"favorites":
[
"color(srgb 0 0 1)",
],
"palettes":
[
],
}
Addition: I don't think it's relevant, but here's my current
User/color-helper.sublime-settings
:
It's not, it looks fine.
Same behavior, same traceback with your palette file.
Sublime Text uses its own bundled Python, right?.. System-wide I have Python 3.10.1 as a default, but it shouldn't be relevant here, if I understand right.
I think I understand the issue, I'm just not sure why I'm not seeing it, but you are. Basically, when we are "updating" the version in the palette file, we are using a list of integers, but this does not convert to a string in the way we are performing our action:
Python 3.3>>> '.'.join((2, 0))
Traceback (most recent call last):
File "__main__", line 1, in <module>
TypeError: sequence item 0: expected str instance, int found
Those integers need to become strings:
Python 3.3>>> '.'.join(str(x) for x in (2, 0))
'2.0'
Look, the line in question is:
'color_helper_palettes_format': '.'.join(PALETTE_FMT),
and PALETTE_FMT = (2, 0)
, I thought the same, more or less. How did it work before, then? Was there a breaking change somewhere?
Was there a breaking change somewhere?
Probably, but who knows when. When I update the palette formats, I usually test upgrade goes smoothly, because it has to for me to test it 🙂. But it is possible that after the initial test, I refactored things.
It's a pain to unit test a Sublime plugin, so there really aren't any unit tests for functionality like this, so things like this get missed. The underlying color library though (coloraide
) is fully unit tested though. It drives all the color manipulations and such.
I know some people use the palettes, but I'm not sure how many, so the fact that no one has noticed for who knows how long may just suggest that the palette features aren't as utilized as maybe some of the other features. I'm usually pretty quick about fixing such issues if they are brought to my attention.
With the line dirty-fixed palettes seem to work again (not heavily tested yet):
'color_helper_palettes_format': '.'.join(str(x) for x in PALETTE_FMT),
That's basically the fix I'll be pushing. I can't forsee any issues. Like I said, most likely the issue was the result of me refactoring and forgetting the context in which the variable was used in all places.
I do use ColorAide, never had any problems with it so far, although I suspect it's a bit sub-optimal (speed-wise) for my (rather specific) needs. Doesn't matter, though, I don't hesitate to cache/memoize a lot, and it doesn't bother me ("speed-wise", again).
As for palettes… I don't really use them myself a lot, but with GraphViz I am suffering badly from the fact that they don't support any ways of styling except for SVG output (and in my "pipeline" I'm kind of tied to using PNG output), so… palettes might make life just a little bit easier… No guarantees, though.
Anyway, thanks for quick reply and fix!
I do use ColorAide, never had any problems with it so far, although I suspect it's a bit sub-optimal (speed-wise) for my (rather specific) needs. Doesn't matter, though, I don't hesitate to cache/memoize a lot, and it doesn't bother me ("speed-wise", again).
Yeah, I get that, speed was never the priority, though we do try to optimize where we can.
One reason that pushed me to write it was this plugin TBH. So the way in which it is done lends itself well to this use case. Additionally, it is meant to be convenient to use. There are plenty of color libraries out there, and some are much quicker but can be more awkward to use. For instance, https://www.colour-science.org/. A fantastic tool. Absurdly, good support for colors etc. Great for scientific plots, etc. But a bit cumbersome for the layperson to use, but again, a great tool.
Aha, I know this one, and maybe I will even have to use it again at one point, when I need more control and precision (it's about some color-blindness related research in my free time - I'm slightly color-blind myself, that's why the interest). But I agree that it is, uhm, a bit too scientific at (most) times :) Not for cases when you just need simple solutions to simple problems. And yes, there are others (colorspacious, colormath, for example); they don't support Oklab, though, and are not actively maintained anymore.
Description
Palettes are either not working or it is not clear from the documentation how to use them.
To isolate the problem, I removed (uninstalled) all other color-related packages (highlighters, pickers, converters) and cleared their caches. The problem remains.
Support Info
Steps to Reproduce Issue
minimal.dot
:or
minimal.css
:Click the red square before the "#ff0000" for the tooltip, click "Palettes". Nothing happens.
Alternatively, select "#ff0000", right-click, "Color Helper", "Color Palettes". Nothing happens.
Additional info:
I can click the star to "Save to Favorites", and it remains shown starred on the next invocation, but I have no access to any "palette" containing starred colors.
So, the question: what am I doing wrong?