microsoft / vscode

Visual Studio Code
https://code.visualstudio.com
MIT License
163.15k stars 28.83k forks source link

New settings editor should work for some compound setting types #55794

Closed roblourens closed 6 years ago

roblourens commented 6 years ago

Also, enum | boolean. Example:

"git.autoRepositoryDetection": {
    "type": [
        "boolean",
        "string"
    ],
    "enum": [
        true,
        false,
        "subFolders",
        "openEditors"
    ],
JacksonKearl commented 6 years ago
  // Specifies the icon theme used in the workbench or 'null' to not show any file icons.
  //  - null: No file icons
  //  - vs-minimal
  //  - vs-seti
  "workbench.iconTheme": "vs-seti",

  // List of tags, comma separated, where the content shouldn't be reformatted. 'null' defaults to the 'pre' tag.
  "html.format.contentUnformatted": "pre,code,textarea",

  // List of tags, comma separated, that should have an extra newline before them. 'null' defaults to "head, body, /html".
  "html.format.extraLiners": "head, body, /html",

  // Maximum number of line breaks to be preserved in one chunk. Use 'null' for unlimited.
  "html.format.maxPreserveNewLines": null,

  // List of tags, comma separated, that shouldn't be reformatted. 'null' defaults to all tags listed at https://www.w3.org/TR/html5/dom.html#phrasing-content.
  "html.format.unformatted": "wbr",

  // Sets the locale used to report JavaScript and TypeScript errors. Requires using TypeScript 2.6.0 or newer in the workspace. Default of `null` uses VS Code's locale.
  "typescript.locale": null,

These are the settings explicitly null | string that I could find with a simple search. Of these, the HTML ones are the only concern. For most of them we should probably just get rid of accepting null, as it doesn't make a ton of sense to have null just mean either default or some secondary default.

But "html.format.unformatted" has very different behavior between null and '' so we'll have to decide on something to do there.

JacksonKearl commented 6 years ago
bpasero commented 6 years ago

@JacksonKearl @roblourens can you add some steps for how to verify?

roblourens commented 6 years ago

Here are some settings with compound types

Test that they work as you'd expect.

I can't remember which extension has the nullable enum but you can test it with a contribution like

"configuration":{
    "title": "testext",
    "properties": {
        "testext.setting1": {
            "type": [
                "null",
                "string"
            ],
            "enum": [
                "option 1",
                "option 2",
                null
            ],
            "description": "test setting"
        }
    }
}
bpasero commented 6 years ago

@roblourens seems to work for the first one, but not second. e.g. here I cannot type "null":

image

I can only type numbers (I am on Windows).

roblourens commented 6 years ago

For the null|number type, an empty input box will correspond to null in the json