vscode: User settings.json can't be formatted in v1.37

Version: 1.37.0 (user setup) Commit: 036a6b1d3ac84e5ca96a17a44e63a87971f8fcc8 Date: 2019-08-08T02:33:50.993Z Electron: 4.2.7 Chrome: 69.0.3497.128 Node.js: 10.11.0 V8: 6.9.427.31-electron.0 OS: Windows_NT x64 10.0.18362

Steps to Reproduce:

  1. add "workbench.settings.editor": "json", "workbench.settings.useSplitJSON": true to User settings.json
  2. indent a line in settings.json
  3. use prettier to format settings.json
  4. vscode warns in the status bar image

It’s not the case in v1.36.1

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

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Comments: 22 (12 by maintainers)

Most upvoted comments

I got findings. The “solution” (or the reason why it worked) was to close all folders. In short: (for me) formatting settings.json doesn’t work if a folder is open. Update: it seems the same happens when editing keybindings.json.

fmtbug

Could anyone please reopen this?

Just to be clear:

  • It’s not about the old split editor.
  • It happens only with user settings.json.
  • It’s not specific to Prettier (tested others).
  • It happens with any JSON-capable formatter.
  • It started happening on VSCode 1.37.0 (remains in 1.37.1).

I don’t think it’s a Prettier issue because it works with jsonc files normally (also if you try with HookyQR.beautify which also supports jsonc, the same thing happens). Curious thing is that, if you try with the same plugin versions and VSCode 1.36.1 or 1.36.0 it works as expected, so it’s likely not a plugin issue but something that was introduced in 1.37.0. Also, as others have pointed out, it works normally if you open the files via File > Open file so it’s clear it’s not a plugin issue.

@roblourens No, it doesn’t have any comments, although the language mode shows “JSON with comments”. Other jsonc files can be formatted as normal. Again, formatting is only not working if I open settings.json through vscode settings commands.