Skip to content

Inconsistent fewerBraces indentation #3489

@soronpo

Description

@soronpo

Configuration (required)

Please paste the contents of your .scalafmt.conf file here:

version = 3.7.2
runner.dialect = scala3

Command-line parameters (required)

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

Steps

Given code like this:

class Top extends EDDesign:
  process(clk, rst):
    val c = Bits(16) const all(0)
    if (rst)
      y :== c
    else if (clk.rising)
      y :== x
  val myblock = process(all):
    val my_var = Bits(16) <> VAR
    my_var := x
    y :== my_var
  process.forever:
    z :== x
    y :== z
end Top

Problem

Scalafmt formats code like this:

class Top extends EDDesign:
  process(clk, rst):
      val c = Bits(16) const all(0)
      if (rst)
        y :== c
      else if (clk.rising)
        y :== x
  val myblock = process(all):
      val my_var = Bits(16) <> VAR
      my_var := x
      y :== my_var
  process.forever:
    z :== x
    y :== z
end Top

Expectation

I would like the formatted output to look like this (same as the input, in this case):

class Top extends EDDesign:
  process(clk, rst):
    val c = Bits(16) const all(0)
    if (rst)
      y :== c
    else if (clk.rising)
      y :== x
  val myblock = process(all):
    val my_var = Bits(16) <> VAR
    my_var := x
    y :== my_var
  process.forever:
    z :== x
    y :== z
end Top

Workaround

None

Notes

I think that it's worth considering adding an indent.fewerBracesSite option that will control the indentation for fewer braces.

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