Closed alok-mishra closed 6 years ago
@alok-mishra Did you enable the syncing.upload.exclude
setting? If so, Syncing will try to format and merge you remote settings with local settings, because it uses a third-party lib to manipulate the JSON with comments, such as the VSCode Settings file.
@alok-mishra I checked the code and find a bug there... seems that Syncing will format the settings no matter the syncing.upload.exclude
is enabled or not. I'll fix it in the next release. Thanks!
Fixed in https://github.com/nonoroazoro/vscode-syncing/commit/75444ff49c09a1088e9a1452cd3304e88435f0b4.
@nonoroazoro Thank you very much! Yes I still want to sync my settings.json so can't exclude it.
In your edits, from what I understand, I think you are still formatting, only if the file has been modified.
Should there be another check to see if jsonc has been excluded from formatOnSave? Maybe I'm not understanding it, and it does what I need, but maybe something like this:
if (modified && getFormatOnSave("jsonc")) {
result = format(result);
}
@alok-mishra That makes sense, the formatOnSave
setting should also be checked before formatting.
@alok-mishra , I've released the new version (latest release) for this feature, enjoy!
Specifications
Expected Behavior
When I download settings, do not format files or at-least respect formatOnSave settings.
Actual Behavior
When I download settings: settings.json gets formatted, even with all extensions disabled except for Syncing, and specific rules for not formatting jsonc.
Steps to Reproduce
Add new lines / spaces between groups and blocks and on top of comments inside settings.json.
Also add rules to disable formatting, including jsonc.
Restart VS Code
Then > Ctrl+Shift+P > "Syncing: Download Settings"
View settings.json. It has been formatted to remove all spaces between blocks and above comments.
Personally I do want formatOnSave, but I would like it not to format settings.json so atleast the "[jsonc]" rule should be followed. Other formatting extensions and the built-in formatter respects this rule.
Thank you for this great extension.