microsoft / vscode

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

getConfiguration() always pulls defaults, even when workspace settings are present #212220

Closed jhechtf closed 6 months ago

jhechtf commented 6 months ago

Does this issue occur when all extensions are disabled?: No

Steps to Reproduce:

  1. Create an extension project through the yo generator given in the docs
  2. Add in a contributes.configuration of
      "gitAngular.alwaysPresent": {
          "title": "Perpetual",
          "scope": "window",
          "type":"object",
          "default": {
            "jim": "is always here"
          }
        },
  3. In a project's settings.json file add in an entry, which should override the values, like such
    "gitAngular.alwaysPresent": {
    "bob": "is a critical member of the team"
    },
  4. Attempt to get the configuration with the following code, registered in any command your extension offers
    const config = workspace.getConfiguration('gitAngular');
    console.info('TESTING', config.get('alwaysPresent');
  5. Output should include both "bob" and "jim" keys, e.g. image
sandy081 commented 6 months ago

This is designed. We do not override object types, instead we merge them. This is true for all settings of type object.

jhechtf commented 6 months ago

Could I get an explanation because that is not at all what I would expect.

sandy081 commented 6 months ago

This is what the expected behaviour for most of the settings of such type for eg., *.exclude