Skip to content

Side-by-side diff drops field comments on the proposed side only #88

@peczenyj

Description

@peczenyj

Problem

In side-by-side diff mode, the current column shows trailing/doc comments after field definitions, but the proposed column omits them. This makes a pure reordering look like it also deletes the field comments.

Example:
```
current │ proposed
───────────────────────────────────────────────────┼──────────────────────────
type Layout struct { │ type Layout struct {
TypeParams string // for a generic type ("[T]")│ TypeParams string
Note string // optional caveat shown ... │ Note string
... │ ...
```

Root cause

Upstream `fieldalignment` deliberately clears each field's `Doc`/`Comment` when building the suggested-fix text (`fieldalignment.go`: `f.Comment = nil; f.Doc = nil`, TODO golang/go#20744). structalign reads `Original` from raw source (comments intact) but takes `Proposed` straight from that comment-less fix text — hence the asymmetry.

Fix

Normalize both sides identically: strip per-field comments from the original too (and keep tags only when `-tags` is set), so the diff shows only the reordering. Falls out of a shared reprint helper.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions