richie5um / vscode-sort-json

VSCode Extension to Sort JSON objects
https://marketplace.visualstudio.com/items?itemName=richie5um2.vscode-sort-json
MIT License
110 stars 19 forks source link

Adhere to "files.insertFinalNewline": true ? #85

Open mgzenitech opened 8 months ago

mgzenitech commented 8 months ago

I have this extension setup together with https://marketplace.visualstudio.com/items?itemName=pucelle.run-on-save:

  "runOnSave.commands": [
 {
   "async": false,
   "command": "sortJSON.sortJSON",
   "match": ".*\\.json$",
   "runIn": "vscode"
 }
  ]

So basically I can use delayed saves and trigger whatever command I need.

The issue is that I have "files.insertFinalNewline": true set and vscode-sort-json extension doesn't follow this setting. Final result is infinite loop of resaves as after initial save by this extension vscode adds missing empty line at the end and this triggers again sortJSON.sortJSON which removes empty line. Maybe this extension could ensure that at least if this setting is set to true the produced json also has empty line at the end?

richie5um commented 8 months ago

Thanks for the comment and the config. I haven't updated this extension for a long time, so probably a few things I need to fix up. I'll add to my todo list and hope to get to it soon.