Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
bnbarham opened this issue Jan 3, 2025 · 2 comments · Fixed by #910

Comments

@bnbarham
Copy link
Contributor

bnbarham commented Jan 3, 2025

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

@andre-richter
Copy link
Contributor

Related (or a dup?) to #807

@ahoppen
Copy link
Member

ahoppen commented Jan 5, 2025

Yes, that looks like a dupe. Thanks for noticing, @andre-richter 🙏🏽

@ahoppen ahoppen closed this as completed Jan 5, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants