"import" comment deleted after "Optimize Imports" command


Hello, I just noticed that a comment after an import statement is no longer present after optimization!

Before <ctrl-alt-o>:

After <ctrl-alt-o>:


My IDEA version is:

IntelliJ IDEA 2022.2.3 (Ultimate Edition)
Build #IU-222.4345.14, built on October 5, 2022
Licensed to ...
Subscription is active until ...
Runtime version: amd64
VM: OpenJDK 64-Bit Server VM by JetBrains s.r.o.
Windows 10 10.0

Could this be a bug?

Comment actions Permalink

Looks like it is a known problem https://youtrack.jetbrains.com/issue/IDEA-128133

As a workaround, you can perform reformat code action for such files with `Code | Reformat File... | Optimize Imports` option disabled.

Comment actions Permalink

Thanks Egor for the hint.


Please sign in to leave a comment.