Unable to format vscode user profile level `settings.json` file
Describe the bug
Extension 'Deno' is configured as formatter but it cannot format 'JSON with Comments'-files
The denoland.vscode-deno extension is ONLY cannot format the user profile level settings.json file.
But it can format the workspace level settings.json file or the *.jsonc file within the workspace.
This is very strange but I think it might be solved in vscode extensions since Prettier - Code formatter extension works in all files mentioned above.
This is actually consistent with #840, but I think it defines the scope of the issue more clearly here, and the possibility of a fix.
I've also tested adding "editor.formatOnSaveMode": "file" but it has no effect.
Like said in the comment, if you drag that settings.json as a file into vscode to open it works, but not when opening the file directly from entrances within vscode.
NOTE that the Prettier extension works in both cases, so there must be a way around it.
Not supporting formatting of user profile level settings.json file is very inconvenient, for example I cannot set "denoland.vscode-deno" to user level "editor.defaultFormatter" because it does not work in the file itself.
Instead I have to configure "denoland.vscode-deno" individually in each workspace.
I hope someone can investigate and resolve this humble little issue. And I'm perfectly willing to set this to my user level "editor.defaultFormatter" once this issue is resolved.
Versions
vscode: 1.95.2 deno: 2.0.6 extension: 3.42.0
Also reproducible with keybindings.json a.k.a. workbench.action.openGlobalKeybindingsFile a.k.a. Preferences: Open Keyboard Shortcuts (JSON).
@dogfuntom Thank you for adding.
I'm assuming user level jsonc config files may all have the same issue.
@qupig Do you use WSL on Windows by any chance? I encountered this issue but it turns out it's because the user settings file is in a Windows directory.
@nayeemrmn No, I'm in macOS.
@nayeemrmn, I think the problem is that the settings.json file does not have a "file" scheme but rather "vscode-userdata" for which the extension is not registered. Extension is currently registered for the "file" and "untitled" schemes (for the jsonc file type, of course). I was able to replace the schema in my LSP (as a proof of concept) and the file is formatted
According to @redking00's instructions, I found this in prettier extension:
https://github.com/prettier/prettier-vscode/blob/b8d9e42b8900c88e2210bc72615d9f925439b058/src/PrettierEditService.ts#L337-L340
It seems that the issue can finally be solved. 🎉