Formatting is not preserved in imports renamed with =>
See original GitHub issueIf I have the following imports (formatted with spaces.inImportCurlyBraces = true
in scalafmt, which adds spaces within the curly braces), and if they are already correctly organized:
import bar.{ Bar => Baz }
import foo.{ Foo1, Foo2 }
then organize-imports preserves the formatting of the second line, but not the first line (the spaces within the curly braces are removed):
import bar.{Bar => Baz}
import foo.{ Foo1, Foo2 }
I have only noticed this in lines where an import is renamed using the =>
syntax.
This is not a problem in my opinion for formatting code (we just run organize-imports first, and then scalafmt, which makes sense anyway) ; but it’s an issue when checking already formatted code with the -check
option, since it detects a difference.
I tested with the following configuration:
OrganizeImports {
coalesceToWildcardImportThreshold = 50
expandRelative = false
groupExplicitlyImportedImplicitsSeparately = false
groupedImports = Merge
groups = ["re:javax?\\.", "scala.", "*", "my.app.package"]
importSelectorsOrder = SymbolsFirst
importsOrder = SymbolsFirst
removeUnused = true
}
Issue Analytics
- State:
- Created 3 years ago
- Comments:8 (5 by maintainers)
Top Results From Across the Web
Excel data doesn't retain formatting in mail merge - Office
In the Microsoft Excel dialog box, under Named or cell range, select the cell range or worksheet that contains the data that you...
Read more >Add text to frames in InDesign - Adobe Support
Imports Word footnotes. Footnotes and references are preserved, but renumbered based on the document's footnote settings. If the Word footnotes ...
Read more >liancheng/scalafix-organize-imports: A CI-friendly ... - GitHub
A CI-friendly Scalafix semantic rule for organizing imports - GitHub ... according to the configuration, its original source level format is preserved.
Read more >Preserve Address Format on Import - Slate Knowledge Base
The Preserve formatting check box is a way to set an address to a quality of 1, so it does not run through...
Read more >Editing Python in Visual Studio Code
User defined symbols (those not coming from installed packages or libraries) are only automatically imported if they have already been used in files...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I can confirm that it also works on my real project. 👍
BTW, I had already tested this tool with a colleague, over the past few weeks, on another project (with different formatting rules, so it didn’t show the same issue) and we’ve been super happy with it. 🙂
Thanks for the feedback, I’m closing this one and will prepare for the 0.4.4 release to include this fix.