Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Maintain manual line breaks within concatenated annotation #1506

Open
wuservices opened this issue Sep 19, 2019 · 1 comment

Comments

@wuservices
Copy link

@wuservices wuservices commented Sep 19, 2019

This template is a guideline, not a strict requirement.

  • Version: 2.0.1
  • Integration: IntelliJ
  • Configuration:
version = "2.0.1"
continuationIndent.callSite = 2
continuationIndent.defnSite = 2
align = none
align.openParenDefnSite = true
align.tokens = []
optIn.configStyleArguments = false
maxColumn = 120
newlines.alwaysBeforeTopLevelStatements = true
assumeStandardLibraryStripMargin = true
includeCurlyBraceInSelectChains = false
rewrite.rules = [PreferCurlyFors, AsciiSortImports, SortModifiers, RedundantBraces, RedundantParens]
rewrite.redundantBraces.stringInterpolation = true
rewrite.redundantBraces.includeUnitMethods = false
rewrite.redundantBraces.generalExpressions = false
rewrite.redundantBraces.methodBodies = false
rewrite.sortModifiers.order = [
  "`sealed`"
  "`abstract`"
  "`override`"
  "`private`"
  "`protected`"
  "`implicit`"
  "`final`"
  "`lazy`"
]
project.git = true

Steps

Given code like this:

  @annotation(
    "Here is a really long string, which needs to be wrapped." +
      " scalafmt forces this concatenated string onto a single line" +
      " but it would be preferable for it to behave like it does for the string below."
  )
  val SomeLongString = "Here is a really long string, which needs to be wrapped." +
    " This split string will stay wrapped properly, but the same string in the annotation" +
    " won't and is forced to be on a single line."

When I run scalafmt like this:

Run format in IntelliJ with it configured to use scalafmt

Problem

Scalafmt formats code like this:

  @annotation(
    "Here is a really long string, which needs to be wrapped." + " scalafmt forces this concatenated string onto a single line" + " but it would be preferable for it to behave like it does for the string below."
  )
  val SomeLongString = "Here is a really long string, which needs to be wrapped." +
    " This split string will stay wrapped properly, but the same string in the annotation" +
    " won't and is forced to be on a single line."

Expectation

I would like the formatted output to look like this:
[Unchanged within the annotation]

Workaround

None known. I just have super long strings within my long annotations.

@poslegm

This comment has been minimized.

Copy link
Collaborator

@poslegm poslegm commented Nov 9, 2019

Minimal config for reproduce:

version = 2.2.2
rewrite.rules = [SortModifiers]

I suspect that bug is here

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
2 participants
You can’t perform that action at this time.