vscode icon indicating copy to clipboard operation
vscode copied to clipboard

Multiple language-specific editor settings not working the same as separate blocks

Open mprisehk opened this issue 11 months ago • 4 comments

Does this issue occur when all extensions are disabled?: No (because I am using Prettier to demonstrate), though still this seems to be an issue in VS Code.

  • VS Code Version: 1.96.4
  • OS Version: Windows 11

Steps to Reproduce:

  1. When I define my settings.json like this, Prettier IS NOT the formatter used for formatting json files (incorrect behavior):
  "editor.formatOnSave": true,
  "[typescriptreact][json]": {
    "editor.defaultFormatter": "esbenp.prettier-vscode"
  },
  "editor.defaultFormatter": "esbenp.prettier-vscode",
  1. When I define my settings.json like this, Prettier IS the formatter used for formatting json files:
  "editor.formatOnSave": true,
  "[typescriptreact]": {
    "editor.defaultFormatter": "esbenp.prettier-vscode"
  },
  "[json]": {
    "editor.defaultFormatter": "esbenp.prettier-vscode"
  },
  "editor.defaultFormatter": "esbenp.prettier-vscode",

The only difference between the two settings.json snippets is that in the first, the language-specific instructions are combined into one line (as introduced in issue 51935, and documented https://code.visualstudio.com/docs/getstarted/settings#_multiple-languagespecific-editor-settings), while in the second they are defined as separate blocks.

As far as I understand, the behavior between the two should be exactly the same.

I have tried both "[json][typescriptreact]" and "[typescriptreact][json]", but in neither case will Prettier be the active formatter in JSON files. Only when using the "[json]" language tag on its own it will work.

mprisehk avatar Jan 22 '25 16:01 mprisehk

Thanks for creating this issue! It looks like you may be using an old version of VS Code, the latest stable release is 1.96.4. Please try upgrading to the latest version and checking whether this issue remains.

Happy Coding!

Now updated to latest, still the issue remains.

mprisehk avatar Jan 22 '25 16:01 mprisehk

fyi @sandy081 this doesn't seem to be a duplicate of previous issues. It sounds like the User-scoped but language-specific "[typescriptreact][json]" version of the setting is not overriding the User-scoped version of the setting.

rzhao271 avatar Jan 24 '25 19:01 rzhao271

Can you please share all your user settings and workspace settings to reproduce the issue?

sandy081 avatar Mar 07 '25 09:03 sandy081

This issue has been closed automatically because it needs more information and has not had recent activity. See also our issue reporting guidelines.

Happy Coding!