microsoft / vscode

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

Default language settings override multiple language ones #206460

Closed memeplex closed 7 months ago

memeplex commented 7 months ago

Default language specific settings override explicit multiple language settings.

For example:

  "[markdown][typst]": {
    "editor.wordWrap": "bounded",
    "editor.tabSize": 4,
    "editor.lineNumbers": "off",
    "editor.rulers": [],
  },

At least regarding wordWrap I know it's set as a language default. Moreover, after separately setting the same options for both languages, all of them are correctly configured.

I don't think this behavior is convenient or intuitive. Explicitly set options, even if they are for a union of languages, should override implicit default ones.

memeplex commented 7 months ago

I don't think this behavior is convenient or intuitive

According to https://code.visualstudio.com/docs/getstarted/settings#_settings-precedence it's indeed a bug:

In the following list, later scopes override earlier scopes: ... Language-specific default settings - These are language-specific default values that can be contributed by extensions.

Language-specific user settings - Same as User settings, but specific to a language.

There is no distinction between single/multi language setting.

Later in the doc:

"[typescript][javascript]" workspace setting will not override a "[javascript]" user setting.

I guess the logic for single-overrides-multi is not making this distinction:

sandy081 commented 7 months ago

I am not sure if I understood the issue. Can you please be crisp and clear about the issue?

memeplex commented 7 months ago

TBH I'm not sure about what do you expect since I've already given a concrete example, some links to points where the documentation contradicts what's observed and an analysis of what may be the cause, so at the risk of repeating myself consider the following scenarios:

  1. The user sets some option opt for a specific language lang1: "[lang1]": ....
  2. The user sets opt for lang1 and some other language: "[lang1,lang2]": ...
  3. An extension sets a default value for opt in lang1

Currently 1 will override 2 and 3 as expected, but 3 will override 2. This is arguably wrong and doesn't follow the documented behavior as I mentioned before:

According to https://code.visualstudio.com/docs/getstarted/settings#_settings-precedence

In the following list, later scopes override earlier scopes: ...

  • Language-specific default settings - These are language-specific default values that can be contributed by extensions.
  • Language-specific user settings - Same as User settings, but specific to a language.
sandy081 commented 7 months ago

Currently 1 will override 2 and 3 as expected, but 3 will override 2.

This seems to be contradicting your statement. If one overrides 2 and 3 and how 3 can override 2? Hence, I am asking for repro steps

memeplex commented 7 months ago

I don't see the problem, 1 overrides 3 overrides 2, so 1 overrides both of them.

sandy081 commented 7 months ago

I don't see the problem

Then what is the problem? To get rid of confusion, please provide clear steps to reproduce with a concrete example and what is current behaviour and what do you expect?

memeplex commented 7 months ago

I've thoroughly explained everything. The problem is in 3 overrides 2, of course. As I've defined:

  1. The user sets opt for lang1 and some other language: "[lang1,lang2]": ...
  2. An extension sets a default value for opt in lang1

I'm going to spell "3 overrides 2": A default value set by an extension for a language overrides a value set by the user for the same language (alongside another language, as in [lang1,lang2]).

But, for the third time, the documentation states:

In the following list, later scopes override earlier scopes: ... Language-specific default settings - These are language-specific default values that can be contributed by extensions. Language-specific user settings - Same as User settings, but specific to a language.

If you don't see the contradiction in that, then I don't have anything else to add.

sandy081 commented 7 months ago

I'm going to spell "3 overrides 2": A default value set by an extension for a language overrides a value set by the user for the same language (alongside another language, as in [lang1,lang2]).

This should not happen, if an extension contributes default value for a language and user also defines a value for the same language, then user value should be taken. If this is not happening, I would request to provide proper step by step set up for me to reproduce. Giving steps will help both of us to be on same page.

memeplex commented 7 months ago

I've provided an example in the opening post, but then again:

  1. Put this into your settings:

    "[markdown][latex]": {
    "editor.wordWrap": "bounded",
    },
  2. Create and open a markdown file

  3. See how wordWrap is not bounded

  4. Change the settings to:

    "[markdown]": {
    "editor.wordWrap": "bounded",
    },
  5. See how wordWrap is now bounded

sandy081 commented 7 months ago

/duplicate

https://github.com/microsoft/vscode/issues/168411

Thanks, this is helpful. Now I understand that settings of single language in default settings is overriding settings of multi language in user settings.

vscodenpa commented 7 months ago

Thanks for creating this issue! We figured it's covering the same as another one we already have. Thus, we closed this one as a duplicate. You can search for similar existing issues. See also our issue reporting guidelines.

Happy Coding!