Skip to content

Run code actions on save #42092

Closed
Closed

Description

Now that we have added code action kinds we could denote them to run on save. Similar to the new command a new setting could exists, e.g. editor.onSaveCodeaction: [quickfix.cleanup, etc.]

Activity

  1. added
    feature-request
    editor-code-actions
    on Jan 24, 2018
  2. mjbvz commented on Apr 16, 2018

    @mjbvz
    Contributor

    A few potential designs for this feature:

    editor.onSaveCodeaction User Setting

    Add a user setting that lists code action kinds that should be run on save.

    Pro

    • Easily customizable by user.
    • Does not require extensions to adopt any new APIs

    Con

    • The setting is not very discoverable or easy to explain.
    • What should the default value be?
    • What if java want organize imports to be run on save but typescript does not? (I know you can use "[java]": { "editor.onSaveCodeaction": [...]})

    Add a new CodeAction.runOnSave property

    Add a runOnSave property to the CodeAction class. Use this property to determine which code actions to run on save

    Pro

    • Lets extensions fully control which actions should be run on save
    • The runOnSave property could be controlled by a more explicit setting such as "typescript.organizeImports.runOnSave": true

    Con

    • Requires extension adoption
    • Could lead to lots of extension specific settings such as, "typescript.organizeImports.runOnSave": true

    Other open questions

    • How do we handle multiple code actions that should be run on save? These may return conflicting edits
  3. jrieken commented on Apr 17, 2018

    @jrieken
    ContributorAuthor

    I think I'd prefer option 1. We could help with the discoverability by adding the predefined code action kinds to the json-schema. It's also more similar to the keybindings story we have around code actions.

  4. added a commit that references this issue on Apr 20, 2018
    c29f432
  5. locked and limited conversation to collaborators on Jun 4, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

apiapi-proposaleditor-code-actionsfeature-requeston-testplan

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions