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

Line break is added when using newlines.source = keep with a trailing comment #4744

Open
domagojlatecki opened this issue Jan 26, 2025 · 0 comments

Comments

@domagojlatecki
Copy link

Configuration

version = "3.8.6"

runner.dialect = "scala3"

newlines {
  source = keep
}

Command-line parameters

When I run scalafmt via CLI like this: scalafmt -c .scalafmt.conf src/app/main/scala/Snippet.scala

Steps

Given code like this:

val _ = println( //
  x = "string"
)

Problem

Scalafmt formats code like this:

val _ =
  println( //
    x = "string"
  )

Expectation

I would like the formatted output to look like this:

val _ = println( //
  x = "string"
)

Workaround

Versions prior to 3.8.4 do not have this problem. Removing newlines.source = keep fixes the issue, but it formats other things differently.

Notes

The trailing comment in the example above is a workaround I have been using to avoid this kind of formatting:

val _ = println(x =
  "string"
)

This case is caused by optIn.configStyleArguments = false which I use.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant