longkai / kubernetes-yaml-formatter

Kubernetes Style YAML Formatter for Visual Studio Code
MIT License
41 stars 3 forks source link

Format on save does not work with "editor.formatOnSaveMode": "modifications" #9

Closed pre closed 1 week ago

pre commented 1 year ago

Format works when selecting >Format document.

However, with "editor.formatOnSaveMode": "modifications" in global user settings format on save does not work. Format on save does work

Project .vscode/settings:

  "[yaml]": {
    "editor.defaultFormatter": "kennylong.kubernetes-yaml-formatter",
    "editor.formatOnSave": true
  },
  "files.associations": {
    "*.yml": "yaml",
    "*.yaml": "yaml"
  },
longkai commented 1 week ago

Hi! Thanks for reaching out.

The editor.formatOnSaveMode works because the default value file formats the entire file every time you save it.

On the other hand, the modifications formats only the lines that have been modified since the last save(requires vcs like git). It’s useful in reducing the amount of change applied during formatting in collaborative settings or when you’re concerned about large files.

pre commented 1 week ago

Yes! And at the time of writing, the latter setting did not work.