Skip to content

NoEmptyLinesOpeningClosingBraces should respect comments when determining which blanks lines are at the beginning/end of a function #909

Closed
@bnbarham

Description

@bnbarham

The NoEmptyLinesOpeningClosingBraces swift-format option will remove blank lines from the beginning/end of blocks, eg.

func myFunc() {

    var x = 3
    return x

}

is reformatted into:

func myFunc() {
    var x = 3
    return x
}

But comments are ignored, eg.

func myFunc() {
    // Some comment here

    // Do a thing
    var x = doAThing()

    // Some other comment here
}

ends up as:

func myFunc() {
    // Some comment here
    // Do a thing
    var x = doAThing()
    // Some other comment here
}

I would expect the input to remain unchanged in this particular case.

rdar://141589363

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