opened
mjbvz
username_0
**Problem**
VS Code ships with multiple actions that can be triggered on save, including:

- Trim trailing whitespace
- Trim trailing new line
- format document
- code actions (such as `organize imports` and `fix all`)

Each of these actions currently has its own setting. Many of the setting names are generic so it may not be clear they apply on save. 

**Goals**
- Make it easier to discover built-in `do X on save` actions
- Give these settings a more consistent names 
- Potentially allow these actions to be used in a more flexible way (such as from the source action menu)
Unifying "do X on save" functionality
issue
created
mjbvz
username_0
## Sketch 1 — Everything is a source Action
Convert all on save actions into source code actions. Use the single `editor.codeActionsOnSave` setting to enable or disable individual actions:

```ts
"editor.codeActionsOnSave": {
      "source.organizeImports": true,
      "source.format": true,
      "source.trimTrailingNewLines": true,
}
```

**Pros**
- Single setting `editor.codeActionsOnSave``
- You can easily create keybindings for source actions
- They would show up in the source context menu.

**Cons**
- Order that actions are run in becomes less clear. With our current implementation, we always run code actions and then format for example
- Creating some code actions, such as format actions, may be expensive.
comment
created
mjbvz
username_0
## Sketch 2 — Tagging settings that control `do X on save`
Tag all settings related to on save. This would allow users to search `@tag:onSave` or similar in the settings view to see all settings related to on save

**Pros**
- Easy to implement
- Makes on save actions more clear

**Cons**
- Still lots of settings
- How would users discover they can search `@tag:onSave`?
comment
created
mjbvz
username_0
## Sketch 3 — Add a new setting

Add a new `editor.onSave` setting that unifies all of these. This setting would be an array of actions that are run in order:

```json
    "editor.onSave": [
        "format",
        { "codeAction": "bla" },
        "files.trimFinalNewlines"
    ]
```

**Pros**

* Clean
* single setting

**Cons**

* Discoverability
* We'd need to figure out how this new setting plays with all the existing settings
comment
created
paulius-valiunas
username_1
Any progress here? It's really annoying when the built-in formatting clashes with my plugins and messes everything up.
comment
created
ZYinMD
username_2
I'd like to borrow this thread to point out an issue for `autoSave` users: 

Many users who set `files.autoSave` to something like `onFocusChange` have developed the habit of never pressing Cmd-S in their workflow. For them, "do X on save" means nothing in the current version of VSCode, because it's never triggered.

Ironically, `Files: Auto Save` is the VERY FIRST item you see when you open settings by `Cmd + ,`, so even the newest users are very likely to change it to some non-default value. (the default is "off")
comment
created
julie777
username_3
I have already seen a document somewhere claiming that code save actions are an array and applied in order. If not, then changing to an array in the settings and running them in order is not a difficult fix.
comment