Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
mprisehk opened this issue Jan 22, 2025 · 2 comments
Assignees

Comments

@mprisehk
Copy link

mprisehk commented Jan 22, 2025

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.

Copy link

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!

@mprisehk
Copy link
Author

Now updated to latest, still the issue remains.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants