Skip to content

BasicFormat indents closure parameter #1473

Open
@bnbarham

Description

@bnbarham
func testClosureParam() {
  var input = Parser("""
    foo(someClosure: { _ in
        return 1
    })
    """)
  let call = ExprSyntax.parse(from: &input)

  let formatted = call.formatted()
  assertStringsEqualWithDiff(formatted.description, """
    foo(someClosure: { _ in
        return 1
    })
    """)
}

Produces:

failed - Actual output (+) differed from expected output (-):
–foo(someClosure: { _ in
–    return 1
–})
+foo(someClosure: { _ in 
+        return 1
+    })

Note the double indent on return 1 and indent of }. Presumably we're always indenting on newlines within parameters of call expressions and then again from the code block.

Metadata

Metadata

Assignees

No one assigned

    Labels

    BasicFormatIncorrect formatting by BasicFormatbugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions