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

remove trailing commas if they exist from selectedText #14

Closed cheazy closed 6 years ago

cheazy commented 6 years ago
{
    "standard.semistandard": true, 
    "ruby.lint": {
        "rubocop": true
    },
}

was turning into

{
    "ruby.lint": {
        rubocop: true
    },
    "standard.semistandard": true
}

this fixes that, but I don't think this is the best approach (using regex on a JSON).

for example: this will get mangled:

{
    "foo": ", }" 
}
richie5um commented 6 years ago

Thanks. I'll have a think before merging this, as I'm not entirely convinced that the regex idea is the right one.

Thanks for taking the time to do the work and submit a PR though. :-)

richie5um commented 6 years ago

Hi. Thank you very much for your PR. I decided to fix it a slightly different way - now published as v1.11.0. Please can you let me know if this doesn't do what you'd hoped for. I also included your menu commands - which I've not used or tested. Hope this is all ok. Thanks again!

cheazy commented 6 years ago

Thanks! Works for me.

The menu buttons should work exactly like they do in the command palette and only show up when right clicking inside of JSON and JSON with Comments files.