Skip to content

Extraneous indentation if the formatted node has parents #1744

Closed
@ahoppen

Description

@ahoppen

The following new test case fails

let decl: DeclSyntax = """
  func test() {
    print(1)
  }
"""

let body = decl.cast(FunctionDeclSyntax.self).body!

let expectedFormatted = """
  {
      print(1)
    }
  """

assertStringsEqualWithDiff(body.formatted().description, expectedFormatted) // fails: `print` is indented by 8 spaces
assertStringsEqualWithDiff(body.detach().formatted().description, expectedFormatted) // passes

For some reason we are adding 8 spaces in front of print if body is not detached.

Metadata

Metadata

Assignees

No one assigned

    Labels

    BasicFormatIncorrect formatting by BasicFormat

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions