Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Disabling sort on save #56

Open
WORMSS opened this issue Aug 18, 2021 · 5 comments
Open

Disabling sort on save #56

WORMSS opened this issue Aug 18, 2021 · 5 comments

Comments

@WORMSS
Copy link

WORMSS commented Aug 18, 2021

It was more difficult that it needed to be to disable sorting on save.

I ended up having to manually write in the settings file

{
    "editor.codeActionsOnSave": {
        "source.fixAll.sortJSON": false
    }
}

Was very annoying.. I am not sure when sort on save became a thing, but I had been blaming vscode for messing up my files for ages until my co-workers who also use vscode were reporting no such problems.

@nerdmax
Copy link

nerdmax commented Sep 28, 2021

^Second that, and thx @WORMSS for sharing the config.

@nerdmax
Copy link

nerdmax commented Sep 28, 2021

Maybe we can have a config for this extension to control the sort on save behavior?

@thany
Copy link

thany commented Feb 23, 2023

Just ran into this issue the other day, in a project that has editor.formatOnSave: true in its project-level configuration. VSCode's default for this setting is false.

I understand there's a tradeoff when adding new functionality to an extension:

  • Making X discoverable by enabling it by default and have users opt-out if they so wish
  • Maintaining current behaviour and giving users the oppertunity to opt into X if and when they are ready to do so

(where X is a placeholder for any new feature that does an automatic thing)

Since formatting on save is an intrusive operation, in the sense that it changes your code, I feel it would have been better to stick with opt-in, and play it safe. That is, if a user happened to have editor.formatOnSave: true set. In other words, source.fixAll.sortJSON: false should've been the default, the way I see it.

@mikestopcontinues
Copy link

It seems that "source.fixAll.sortJSON": false no longer works. After some VSC updates, my package.json files keep getting sorted. I even tried setting:

"sortJSON.excludedFiles": [
    "package.json"
  ],

@mikestopcontinues
Copy link

Update: You should now use the following syntax rather than a boolean:

  "editor.codeActionsOnSave": {
    "source.fixAll": "always",
    "source.fixAll.sortJSON": "never"
  },

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants