Fix formatter non-convergence with EOL comment before else if - #2541
Open
kbrunham-intel wants to merge 1 commit into
Open
Fix formatter non-convergence with EOL comment before else if#2541kbrunham-intel wants to merge 1 commit into
kbrunham-intel wants to merge 1 commit into
Conversation
|
|
Skip merging end into the else partition when end has a trailing EOL comment so fit-else-expand does not oscillate on re-format (issue chipsalliance#2540).
Collaborator
|
Thanks for your contribution - Sorry for the delay in the review, I was a bit busy the last couple of weeks. Looks good. Can you rebase, as there were other changes in the formatter_test that now require a merge ? |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #2540: formatter non-convergence when an EOL comment sits between
endand a followingelse if.When
endcarried a trailing EOL comment,PushEndIntoElsePartitionmerged thatend+comment into the else-if header partition.fit-else-expandthen treated the header as wider than the eventual printed line, so the first format kept the else-if assignment on one line and the second wrap split it —format(format(x)) != format(x).Change: skip merging
endinto the else partition when theendleaf contains an EOL comment (else must start on the next line anyway when preceded by a comment).Test plan
FormatterEndToEndTest.EndElseIfWithEOLCommentConvergescovering comment-on-own-line and comment-already-on-endbazel test //verible/verilog/formatting:formatter_test