Skip to content

Plugin has a conflict with the built-in organize imports #716

@paustint

Description

@paustint

As soon as VScode was updated to 1.31.0, it appears that this prettier extensions conflicts with the the built-in organize imports setting, when organize imports on save is enabled.

prettier: "prettier": "^1.16.4", (was initially on 1.13.7, tried to update)
vscode: Version 1.31.0 (1.31.0)
extension: 1.8.0

I first opened a ticket with vscode core, but was referred to the extension as the source of the problem:
microsoft/vscode#68193

Steps to reproduce

  1. Add setting for editor.codeActionsOnSave.source.organizeImports = true (see below for example json)
  2. Ensure prettier is configured to format on save
  3. create a ts file (may also work with js) that has an import that exceeds the configured line length, which should be turned into a multi-line import
  4. Save file

Expected behavior:

  1. imports should be organized
  2. imports should be formatted to multi-line import
  3. file should be saved

Actual behavior:

  1. imports are organized
  2. imports remain on a single line
  3. file remains "dirty" - with the little white dot in the tab-bar

Note:
I can format the document manually using the command menu and the import is correctly formatted, but then on save it is unformatted and the file shows as modified by the file system.

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

Initial file

image

Format file manually, just to show that it works

image

image

After Save (cmd+s)

image

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementlockedPlease open a new issue and fill out the template instead of commenting.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions