ue / alphabetical-sorter

VScode extension - For variable alphabetical re-order
https://marketplace.visualstudio.com/items?itemName=ue.alphabetical-sorter
MIT License
32 stars 3 forks source link

Sort by nested / indentation level instead of globally? #7

Open alexleduc76 opened 4 years ago

alexleduc76 commented 4 years ago

Perhaps this type of feature would only be useful if the file extension is .json or .js, but it would be nice if it could take nested JSON or JS object literals:

{
    "workbench.iconTheme": "vscode-icons",
    "zenMode.hideLineNumbers": false,
    "emmet.includeLanguages": {
        "javascript": "javascriptreact"
    },
    "beautify.options": {
        "indent_with_tabs?": true,
        "indent_size?": 1,
        "end_with_newline?": true
    },
    "search.exclude": {
        "**/public/fonts": true,
        "**/public/js": true,
        "**/public/themes": true,
        "**/public/css": true
    }
}

And sort it like this:

{
    "beautify.options": {
        "end_with_newline?": true
        "indent_size?": 1,
        "indent_with_tabs?": true,
    },
    "emmet.includeLanguages": {
        "javascript": "javascriptreact"
    },
    "search.exclude": {
        "**/public/css": true
        "**/public/fonts": true,
        "**/public/js": true,
        "**/public/themes": true,
    }
    "workbench.iconTheme": "vscode-icons",
    "zenMode.hideLineNumbers": false,
}

... and if the last item in a nested list doesn't have one and it's moved to another position in the order, add a comma at the end so that ti doesn't have to be manually fixed after the sort (errors in the format should be highlighted above)

instead of:

        "**/public/css": true,
        "**/public/fonts": true,
        "**/public/js": true,
        "**/public/themes": true
        "end_with_newline?": true
        "indent_size?": 1,
        "indent_with_tabs?": true,
        "javascript": "javascriptreact"
    "beautify.options": {
    "emmet.includeLanguages": {
    "search.exclude": {
    "workbench.iconTheme": "vscode-icons",
    "zenMode.hideLineNumbers": false,
    }
    },
    },
{
}
gusandrioli commented 3 years ago

This happens in any nested data. I'm having the same issue