You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Please paste the contents of your .scalafmt.conf file here:
version = 3.7.12
runner.dialect = scala212
maxColumn = 120
Command-line parameters (required)
When I run scalafmt via CLI like this: coursier launch scalafmt
Steps
Given code like this:
println(""" |A very long string |with multiple lines |""".stripMargin
)
Problem
Scalafmt formats code like this:
println(""" |A very long string |with multiple lines |""".stripMargin) // No newline before closing paren, not aligned with beginning of statement
Expectation
I would like the formatted output to look like this:
println(""" |A very long string |with multiple lines |""".stripMargin
)
Workaround
–
Notes
It works fine when the method is called with multiple arguments:
println(
""" |A very long string |with multiple lines |""".stripMargin,
"ok"
)
I'm assuming that scalafmt (kind of correctly) considers a multiline string to be a single argument so no newline is inserted before the closing paren (same as println("ok")). My rationale is that it would be more consistent if a multiline string actually spanning multiple lines would be considered multiple arguments, in which case scalafmt can be configured to insert a newline before the closing paren.
The behavior for strings using the multiline syntax but actually consisting of a single line is fine:
println("""A pretty short string""".stripMargin)
The text was updated successfully, but these errors were encountered:
I'm fairly certain that there's a configuration parameter which deals with dangling closing parentheses. if you have tried it, please amend the issue; if you haven't, would you mind rtfm, please?
I take it back. There's no parameter that helps with this, since there's no newline after the opening paren. the only option is to insert a newline after ( manually and use newlines.source = keep (or a // comment after ().
otherwise, there's a lot of old code which specifically enables the behaviour you're not happy about. we can't just change it, as it's a breaking change, so the only option is to introduce a new parameter.
and this normally requires socializing this with the larger community on the discord channel and getting them to support a new parameter, of which there are already too many, and most users can't power through the configuration doc.
Configuration (required)
Please paste the contents of your
.scalafmt.conf
file here:Command-line parameters (required)
When I run scalafmt via CLI like this:
coursier launch scalafmt
Steps
Given code like this:
Problem
Scalafmt formats code like this:
Expectation
I would like the formatted output to look like this:
Workaround
–
Notes
It works fine when the method is called with multiple arguments:
I'm assuming that scalafmt (kind of correctly) considers a multiline string to be a single argument so no newline is inserted before the closing paren (same as
println("ok")
). My rationale is that it would be more consistent if a multiline string actually spanning multiple lines would be considered multiple arguments, in which case scalafmt can be configured to insert a newline before the closing paren.The behavior for strings using the multiline syntax but actually consisting of a single line is fine:
println("""A pretty short string""".stripMargin)
The text was updated successfully, but these errors were encountered: