Skip to content
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

Fix NoEmptyLinesOpeningClosingBraces to respect consecutive newlines when a function starts or ends with a comment #910

Merged

Conversation

TTOzzi
Copy link
Member

@TTOzzi TTOzzi commented Jan 4, 2025

Resolve #909

Since we are traversing the leadingTrivia in order to determine whether newlines are respected, we needed to modify the trimmingSuperfluousNewlines function to distinguish whether the leadingTrivia we are traversing is the beginning or end of a block.
For the leadingTrivia of the closingBrace, the handling of newlines was deferred and revised to process them only when the next TriviaPiece is neither a space/tab nor a newline.

…when a function starts or ends with a comment
Copy link
Member

@allevato allevato left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks reasonable to me, thanks!

@allevato
Copy link
Member

allevato commented Jan 6, 2025

I'll kick off the full CI, which should at least make sure that this PR doesn't change the expected formatting of swift-syntax as a safety check.

@TTOzzi
Copy link
Member Author

TTOzzi commented Jan 6, 2025

Thank you! 😄

@allevato allevato merged commit e82cdd7 into swiftlang:main Jan 7, 2025
19 checks passed
@TTOzzi TTOzzi deleted the fix-NoEmptyLinesOpeningClosingBraces branch March 7, 2025 00:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants