Skip to content

Prevent running Fix-All on-save from removing unused imports #4561

Closed

Description

@DanTup

Placeholder for release notes, and for discoverability when this behaviour changes.

Before a recent SDK change, using fix-all-on-save in VS Code would also remove unused imports:

"editor.codeActionsOnSave": {
	"source.fixAll": true
}

This behaviour was a little inconsistent without iterative fix-all (it would not remove the imports if other fixes were applied). Iterative fix-all made it consistent, but this behaviour is not what many users want (for example if they'd temporarily commented out code).

With this change, imports will not be touched when using fix-all if it was invoked automatically by save. However, it's possible to retain the original behaviour by invoked listing the original fix, or (more efficiently) source.organizeImports) to run on-save:

"editor.codeActionsOnSave": {
	"source.fixAll": true,
	"source.organizeImports": true
}

Activity

  1. added
    is enhancementAn enhancement or improvement that should be listed in release notes but is not a bug fix.
    in editorRelates to code editing or language features
    in lsp/analysis serverSomething to be fixed in the Dart analysis server
    on May 24, 2023
  2. added this to the Requires SDK Release milestone on May 24, 2023
  3. DanTup commented on Jun 7, 2023

    @DanTup
    MemberAuthor
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    in editorRelates to code editing or language featuresin lsp/analysis serverSomething to be fixed in the Dart analysis serveris enhancementAn enhancement or improvement that should be listed in release notes but is not a bug fix.

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions