microsoft / vscode

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

VS Code throws when registering dotted languages with language-overridable settings. #186483

Open guiherzog opened 1 year ago

guiherzog commented 1 year ago

Does this issue occur when all extensions are disabled?: Yes (kinda)

Steps to Reproduce:

  1. Create a language extension that contributes a language that has a dot in its name. E.g. lldb.disassembly
    "languages": [
      {
        "id": "lldb.disassembly",
        "aliases": ["Disassembly"],
        "extensions": [".disasm"]
      }
    ],
  2. Add a default language configuration override to a language-overridable setting to its package.json.
    "configurationDefaults": {
      "[lldb.disassembly]": {
        "test.tabSize": 2
      }
    },
  3. Load VS Code with the extension installed and it will show this on the console: Screenshot 2023-06-27 at 17 46 17

Then, the language override setting for that dotted language does not work and it falls back to the default setting.

Investigation: The issue happens when the updateValue() method from the configurationModels.ts tries to access the this.contents object with an non-existing key, the actual reason why that happens is because the key with the name of the language that should be [lldb.disassembly] of the this.contents object gets split by the addToValueTree() method that creates a nested object for dotted settings, such as "editor.tabSize".

Hopefully, this image helps in understanding the issue: Screenshot 2023-06-27 at 17 21 12

Possible solution: I believe this could be solved by adding a check the verifies if the key being added is a language id. Something like if (OVERRIDE_PROPERTY_REGEX.test(key)) {

Since, if the key is a language identifier key, I assume there won't be any need to split since it won't ever be a dotted setting, such as editor.tabSize.

I have a fix that seems to work locally, but would like to hear your thoughts before creating a PR. Do you see any other issues with having dotted languages, such as lldb.disassembly? I could not find any resources explicitly disallowing it, and we have been using it internally without any issues, but this bug was quite tricky to discover and it caused language overrides to not work at all.

guiherzog commented 1 year ago

friendly ping