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

spaces.afterKeywordBeforeParen should be honoured for extension soft keyword #3499

Closed
djneades opened this issue Mar 11, 2023 · 0 comments · Fixed by #3507
Closed

spaces.afterKeywordBeforeParen should be honoured for extension soft keyword #3499

djneades opened this issue Mar 11, 2023 · 0 comments · Fixed by #3507

Comments

@djneades
Copy link

Configuration (required)

.scalafmt.conf:

version = "3.7.2"
maxColumn = 80

runner.dialect = scala3

spaces.afterKeywordBeforeParen = true
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

spaces.afterKeywordBeforeParen does not appear to be honoured for the extension soft keyword at all (whether set to true or false). Instead, it seems that a space is inserted between the extension and the following opening paren only when newlines.beforeOpenParenDefnSite = null. When newlines.beforeOpenParenDefnSite is keep, fold, or unfold, the space is removed.

Note: I always want the space and would thus be happy as long as it is added (or preserved), irrespective of the spaces.afterKeywordBeforeParen setting. At first glance, however, it seems reasonable that the behaviour should follow that setting.

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.

1 participant