fix: numerous bugs found by formatting Nelm#13
Merged
ilya-lesikov merged 9 commits intomainfrom Feb 24, 2026
Merged
Conversation
Signed-off-by: Ilya Lesikov <ilya@lesikov.com>
Var specs are now grouped by exportability only (blank _, exported, unexported) and preserve their original relative order within each group. This prevents breaking initialization dependencies where later vars depend on earlier ones being initialized first. Signed-off-by: Ilya Lesikov <ilya@lesikov.com>
When extracting specs from GenDecl to merge into a single block, doc comments (Decs.Start) and inline comments (Decs.End) on the GenDecl were lost. transferGenDeclDecsToSpecs now transfers them to the first/last spec before discarding the GenDecl. Signed-off-by: Ilya Lesikov <ilya@lesikov.com>
Transfer GenDecl.Decs.End (inline comments) to the last spec's Decs.End. Work around DST limitation where the last spec's End comment in a parenthesized block gets rendered after the closing paren by moving it to Start via fixLastSpecEndComment. Signed-off-by: Ilya Lesikov <ilya@lesikov.com>
Free-floating comments (section headers separated from code by a blank line) on var/const declarations now cause FormatFile to return an error instead of silently corrupting the comment position during merge. Signed-off-by: Ilya Lesikov <ilya@lesikov.com>
Anonymous structs (table tests, inline struct fields, composite literal types) are no longer reordered. reorderStructFields now targets *dst.TypeSpec nodes containing *dst.StructType, skipping all anonymous struct types to preserve table test readability. Signed-off-by: Ilya Lesikov <ilya@lesikov.com>
Structs with json, yaml, xml, toml, or protobuf struct tags now preserve their original field order to prevent changing wire format. Signed-off-by: Ilya Lesikov <ilya@lesikov.com>
assembleFieldList now unconditionally resets both Decs.Before and Decs.After for all fields, preventing stale EmptyLine decorations from the original source from leaking through. Signed-off-by: Ilya Lesikov <ilya@lesikov.com>
Typed const specs (Stage, ReleaseType, etc.) now preserve their original relative order within the same type group. Only untyped consts are alphabetized, keeping intentional orderings intact. Signed-off-by: Ilya Lesikov <ilya@lesikov.com>
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.
No description provided.