Fix module-level alignment breaking after non-alignable constructs - #2500
Open
dannyoler wants to merge 1 commit into
Open
Fix module-level alignment breaking after non-alignable constructs#2500dannyoler wants to merge 1 commit into
dannyoler wants to merge 1 commit into
Conversation
|
|
AlignModuleItems was the only alignment function that did not split partitions by blank lines before classifying alignment groups. When a non-alignable construct (e.g. a module instantiation) appeared in the module body, GetConsecutiveModuleItemGroups returned kNoMatch, which permanently broke the alignment group for all subsequent assign statements and declarations in that scope. This change adds GetModuleItemGroupsBetweenBlankLines, which first partitions by blank lines (using GetSubpartitionsBetweenBlankLines), then runs GetConsecutiveModuleItemGroups within each sub-range. This matches the pattern used by every other alignment function (AlignPortDeclarations, AlignStructUnionMembers, AlignCaseItems, etc.). Before this fix: assign short_a = 1; // aligned assign really_long_name_b = 2; // aligned inst #() u (.Z(z)); // breaks alignment permanently assign c = 3; // NOT aligned assign longer_d = 4; // NOT aligned After this fix: assign short_a = 1; // aligned (group 1) assign really_long_name_b = 2; // aligned (group 1) inst #() u (.Z(z)); // ends group 1, does not affect group 2 assign c = 3; // aligned (group 2) assign longer_d = 4; // aligned (group 2) Blank lines continue to separate alignment groups as expected. Also removes the resolved TODO(b/161814377) comment, as continuous assignment alignment support already exists and now works correctly.
dannyoler
force-pushed
the
fix-module-item-alignment-grouping
branch
from
March 27, 2026 21:21
080095c to
13fba42
Compare
Collaborator
|
Thanks for your contribution. Sorry for the delay, was swamped with other projects and missed the mail from github about the change. Can you have a look at the tests and make them all pass ? |
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
AlignModuleItemswas the only alignment function that did not split partitions by blank lines before classifying groupsGetConsecutiveModuleItemGroupsreturnedkNoMatch, permanently breaking alignment for all subsequentassignstatements and declarations in that scopeGetModuleItemGroupsBetweenBlankLineswhich first partitions by blank lines, then runsGetConsecutiveModuleItemGroupswithin each sub-range — matching the pattern used by every other alignment functionBefore
After
Blank lines continue to separate alignment groups as expected. Also removes the resolved
TODO(b/161814377)comment.Test plan
DFFmacros, and hundreds ofassignstatementsRelated issues: #2021, #2481