source.organizeImports is replicating last comment line · Issue #38507 · microsoft/TypeScript (original) (raw)

Using Code Insiders build:

Version: 1.46.0-insider
Commit: 288852d8c26d797974bfb8aed06e1bff9b809223
Date: 2020-05-12T05:42:38.380Z (12 hrs ago)
Electron: 7.2.4
Chrome: 78.0.3904.130
Node.js: 12.8.1
V8: 7.8.279.23-electron.0
OS: Darwin x64 19.4.0

Problem: If you have organizeImports enabled, such as:

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

and you save a file with comments in the import area, such as:

// comment1
import { Component, h, Prop, State } from "@stencil/core";
// comment2
import { CloudService } from "../../services/cloud";

and then save the file, it will replicate the last comment line under all of the imports like this:

After first save

// comment1
import { Component, h, Prop, State } from "@stencil/core";
// comment2
import { CloudService } from "../../services/cloud";
// comment2

After 2nd save

// comment1
import { Component, h, Prop, State } from "@stencil/core";
// comment2
import { CloudService } from "../../services/cloud";
// comment2
// comment2

Etc...