Gruntfuggly / todo-tree

Use ripgrep to find TODO tags and display the results in a tree view
Other
1.45k stars 142 forks source link

settings.json schema flags color names as invalid #606

Open TonyGravagno opened 2 years ago

TonyGravagno commented 2 years ago

From ReadMe:

Note: Foreground and background colours can be specified using HTML/CSS colour names (e.g. "Salmon"), RGB hex values (e.g. "#80FF00"), RGB CSS style values (e.g. "rgb(255,128,0)" or colours from the current theme, e.g.

Error from current VSCode:

Invalid color format. Use #RGB, #RGBA, #RRGGBB or #RRGGBBAA.

settings.json:

"QUESTION": {
            "foreground": "blue",
            "background": "goldenrod",
            "icon": "question",
            "iconColour": "goldenrod",
            "gutterIcon": true
        },

Screenshot: image

Thanks.

coppinri commented 2 years ago

I've got the same query/issue.

I think this is more of an issue with some changes that have come down from VSCode than for Todo-Tree. Todo-Tree seems to work find dispite the warning.

If anyone knows how to disable this particular warning, that would be great.

I suppose there's always the option to acquiesce and just use the #RRGGBB values.

gerardlt commented 2 years ago

I've just come across the same thing.

Seeing the issue was only raised two days ago and already two more of us have felt it worth commenting on, I'd guess there;s been a recent change in this area.

A quick web search for the warning message got me only two links (surprisingly, given the generic message):

But when I then searched for the message in the vscode repo itself (on github), I additionally found referencesValidation.ts for which the relevant commit was https://github.com/microsoft/vscode/commit/2445428308d74f1eedf73715809dca2d37e21c6d - which also dates from 2020 (November).

So neither of them suggest a recent change. ¯\(ツ)

TonyGravagno commented 2 years ago

Agreed - the issue is not with this extension. I see the same issue in settings for other extensions. I'm poking around at jsonParser.ts and other vectors as well.

Let's leave this here for discussion and I'll close it if/when we find a culprit we can point at.

BTW, from looking around, this extension has a Ton of util code for validating JSON (colors) and so much else. It's seriously rich FOSS.

TonyGravagno commented 2 years ago

All : I think this is our problem and not a bug. I don't see any reference that indicates that a color is accepted in VSCode Settings.

This comment by a VSCode insider @aeschli says the decision was made prior to 2017 to only support RGB.

The schemas show all colors are "format": "color-hex".

The documentation for Color formats says:

Color values can be defined in the RGB color model with an alpha channel for transparency. As format, the following hexadecimal notations are supported: #RGB, #RGBA, #RRGGBB and #RRGGBBAA.

The VSCode JSON language server doc (also written/edited by @aescchli) says:

All values marked with "format": "color-hex" (VSCode specific, non-standard JSON Schema extension) are considered color values. The supported color formats are #rgb[a] and #rrggbb[aa].

Like everyone else here, I've used color names in various places, but I can't say with certainty that I've ever used a color name in VSCode settings.json - and actually had it work. I think I/we are simply wrong to have expected this to work. 😵‍


I'm revising this ticket to be a simple error in the Readme where it says:

Note: Foreground and background colours can be specified using HTML/CSS colour names (e.g. "Salmon"), RGB hex values (e.g. "#80FF00"), RGB CSS style values (e.g. "rgb(255,128,0)" or colours from the current theme, e.g. peekViewResult.background. See Theme Color for the details. Hex and RGB values can also have an alpha specified, e.g. "#ff800080" or "rgba(255,128,0,0.5)".

Correct text should be:

Note: Foreground and background colours can be specified using RGB hex values (e.g. "#80FF00"), and RGB with an alpha specified, e.g. "#ff800080". Full format list: #RGB, #RGBA, #RRGGBB or #RRGGBBAA. See Theme Color for the details.

Agreed?

Gruntfuggly commented 2 years ago

It's sort of my fault - as @TonyGravagno says, the colour settings in the package.json are marked as "format": "color-hex" which allows the json settings view to display the colour swatch next to them (and a colour picker when clicked). However, this only works when an RGB.

The extension is flexible in that it allows colour names to be used in place which are supported in the decorations API, but they obviously don't fit the format, so vscode complains.

I could make them "format": "string" which will get rid of the warnings, but prevent the colour swatch being displayed.

The README.md is correct - you can specify colour names (and they will get used), but if you do, warnings will be shown in the preferences.

Maybe I should update the README.md to warn users?

Gruntfuggly commented 2 years ago

I'm also going to add a command to convert named colours to RGB, so users can use it once they're happy with their colour scheme.

TonyGravagno commented 2 years ago

A very productive thread. Thank you very much, Nigel!