Skip to content

Auto-expand small unchanged gaps between diff hunks #336

@tomasz-tomczyk

Description

@tomasz-tomczyk

When only a few lines (e.g. 3-5) are folded between two diff hunks, the "Expand N unchanged lines" spacer adds visual noise without providing meaningful compression. These small gaps are better shown inline.

Desired behavior: When the gap between two adjacent hunks is below a threshold (e.g. ≤8 lines), automatically expand the context and merge the hunks at render time — no spacer shown.

Implementation approach:

  • Pre-process file.diffHunks before the render loop: merge adjacent hunks where the gap is ≤ threshold
  • This avoids re-entrant renders that would occur if done inside renderDiffSpacer
  • Comments are keyed by line number, so auto-merging doesn't affect comment positioning
  • E2E note: verify that expanded-comments.spec.ts fixture gaps are above the threshold, or adjust fixtures

Purely frontend — no backend changes needed.

Refs #320

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