Skip to content

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

@djneades

Description

@djneades

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions