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
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:
file.diffHunksbefore the render loop: merge adjacent hunks where the gap is ≤ thresholdrenderDiffSpacerexpanded-comments.spec.tsfixture gaps are above the threshold, or adjust fixturesPurely frontend — no backend changes needed.
Refs #320