contributes.configuration configuration property schema: Dropdown menu poorly specified (enum / enumDescriptions / enumItemLabels)
VS Code allows extensions to create settings with predetermined options based on a list of presets. The Contribution Points page's Configuration property schema subsection documents how to do that using the enum / enumDescriptions / markdownEnumDescriptions / enumItemLabels properties. But given how funky the schema is, it would be best to properly specify that part.
Here are a number of specific issues:
- There is no code example of
enumItemLabels. enumis mentioned but not specified.markdownEnumDescriptionsis not mentioned in the title.- "will be rendered as Markdown" would be more accurate as "will be parsed as Markdown".
- The relationship between these 4 properties is unspecified. What happens if both
markdownEnumDescriptionsandenumDescriptionsare set, for instance?
Also, the following:
The
workbench.iconThemesetting uses bothenumDescriptionsandenumItemLabels.In the screenshot below, the hovered option has the item label "None", with enum description "No file icons" and enum valuenull.
…would be clearer as:
For example, the
workbench.iconThemesetting shown below uses bothenumDescriptionsandenumItemLabels. In this screenshot, the hovered option has the item label "None", with enum description "No file icons" andenumvaluenull.
I wish this report is the occasion for a general review of that section but understand that the scope is a little wide. Feel free to consider this as solved once the first specific issue is solved. I will file different tickets for any remaining problems if needed.
@Chealerappreciate you writing this extensive issue description.
The change does solve at least #1, #3 and #4. Thank you very much @rzhao271 :-)
I'm not sure what you'd like for item 2. Are you looking for allowed types, for example? 5 is specified with the phrase "instead of". I'll add a note that the Markdown field overrides the non-Markdown field.
Thanks again @rzhao271
I'm not sure what you'd like for item 2. Are you looking for allowed types, for example?
Yes, that's partially specified but only implicitly. If it's an array of different strings, that should be explicitly specified, specifying how non-unique values are treated. If the dropdown menu contains the same number of items as enum, it would clarify to indicate that.
5 is specified with the phrase "instead of". I'll add a note that the Markdown field overrides the non-Markdown field.
Thanks, that's clearer, but it's still short of a real spec. Due to the schema's funkiness, it remains unclear how VS Code would treat for example the following:
{
"settingsEditorTestExtension.enumSetting": {
"type": "string",
"enum": ["first", "second", "third"],
"enumDescriptions": ["The first enum", "The second enum", "The third enum"],
"markdownEnumDescriptions": ["The first enum *ONLY*"],
"enumItemLabels": ["1st", "2nd", "3rd"],
"default": "first",
"description": "Example setting with an enum"
}
}