Skip to content

Add a wrap toggle for long diff lines - #47

Open
shukebeta wants to merge 1 commit into
minipai:mainfrom
shukebeta:wrap-long-lines
Open

shukebeta wants to merge 1 commit into
minipai:mainfrom
shukebeta:wrap-long-lines

Conversation

@shukebeta

Copy link
Copy Markdown

What

Adds a Wrap checkbox next to the Split/Unified control. Off by default; when checked, every mounted diff re-renders with overflow: 'wrap', so long lines fold instead of hiding behind a horizontal scroll.

@pierre/diffs already supports overflow: 'scroll' | 'wrap' — the report just never passed it. ReportOptions gains wrap?: boolean so a caller can preselect it, mirroring layout. No CLI flag, also mirroring layout.

The toggle reuses the layout path: setOptions({ ...options, overflow }) + render({ fileDiff, forceRender: true }) on the same instances, no remount.

Why

Reviewing a report in half a screen (terminal on one side, report on the other) makes wide hunks unreadable — the interesting end of a long line sits off-screen and the horizontal scroll is per-file.

Tests

  • test/report.test.ts: the checkbox renders, defaults to off, and honours { wrap: true }.
  • test/report-dom.test.ts: toggling flips pre[data-overflow] from scroll to wrap and back on the same diffs-container instances.
  • tsc --noEmit clean; bun test ./test/report.test.ts ./test/report-dom.test.ts 84 pass / 0 fail.

Not done

The visual baselines under test/visual/__screenshots__ will need pnpm test:visual:update — the toolbar row changed. I develop on Windows and can't produce the Linux/DejaVu renders CI compares against, so I left the PNGs alone rather than commit baselines from the wrong platform.

Long lines are only reachable by horizontal scrolling, which makes a wide
hunk hard to read next to a narrow window. @pierre/diffs already supports
overflow: 'wrap'; expose it as a Wrap checkbox beside the Split/Unified
control, off by default, applied to the mounted instances without a
remount.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant