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

newlines.beforeOpenParenDefnSite = unfold unnecessarily wraps extension clause in the presence of a doc comment #3497

Closed
djneades opened this issue Mar 10, 2023 · 3 comments · Fixed by #3506

Comments

@djneades
Copy link

djneades commented Mar 10, 2023

Configuration (required)

.scalafmt.conf:

version = "3.7.2"
maxColumn = 80

runner.dialect = scala3

newlines {
   beforeOpenParenDefnSite = unfold
}

Command-line parameters (required)

When I run scalafmt via CLI like this: scalafmt test.scala

Steps

Given code like this:

extension (s: String)

  /** ... */
  def foo(): Unit = ???
  def bar(): Unit = ???

Problem

Scalafmt formats code like this:

extension
  (s: String)

  /** ... */
  def foo(): Unit = ???
  def bar(): Unit = ???

Expectation

I should like the formatted output to look like this:

extension (s: String)

  /** ... */
  def foo(): Unit = ???
  def bar(): Unit = ???

Workaround

n/a

Notes

Since extension (s: String) easily fits on a single line, it should not be wrapped on to two lines even with newlines.beforeOpenParenDefnSite = unfold.

If the doc comment /** ... */ is removed from before the def foo(), the formatting works as expected (except that there is no space after the extension keyword, but that may be configurable).

@djneades
Copy link
Author

djneades commented Mar 10, 2023

Given that spaces.afterKeywordBeforeParen defaults to true, I am also not sure why (in the absence of the doc comment) the extension line is formatted to extension(ef: EffectMsg) rather than extension (ef: EffectMsg) using the above .scalafmt.conf. Am I misunderstanding something there?

@kitbellew
Copy link
Collaborator

Given that spaces.afterKeywordBeforeParen defaults to true, I am also not sure why (in the absence of the doc comment) the extension line is formatted to extension(ef: EffectMsg) rather than extension (ef: EffectMsg) using the above .scalafmt.conf. Am I misunderstanding something there?

please submit a separate issue.

@djneades
Copy link
Author

please submit a separate issue.

@kitbellew Done! Please see #3499.

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

Successfully merging a pull request may close this issue.

2 participants