fix(diffviewer): wrap long lines through delta in side-by-side, mark clipped lines in unified (closes #99)#133
Open
Booyaka101 wants to merge 1 commit into
Open
Conversation
…clipped lines in unified (closes dlvhdr#99) `diffFile` and `diffDir` were invoking delta with `--max-line-length=<width>`, which is the truncation flag rather than a wrap hint. Combined with delta's default `--wrap-max-lines=2`, that capped any source line at roughly two viewport widths in side-by-side mode and silently dropped the rest. In unified mode, where delta does not wrap, the long line then hit the post- processing truncation in the `diffContentMsg` handler, which used an empty tail and clipped without any visible signal. This commit: - Replaces `--max-line-length=<width>` with `--max-line-length=0` and adds `--wrap-max-lines=unlimited` for both invocations. Side-by-side now wraps long lines all the way to the end instead of truncating after two wraps. Verified locally: a 162-char line at `-w=80` previously stopped at "what flags delta is invoked with"; it now reaches "to see what happens here". - Replaces the empty truncation tail in the `diffContentMsg` handler with `…`, so unified-mode lines that exceed the viewport at least signal the cut-off rather than vanishing silently. The existing `diffviewer` test suite still passes. Pre-existing `TestSearchResultsRenderWhenFileTreeIsHidden`, `TestBuildFullFileTree`, and `TestCollapseTree` failures on `main` are unrelated to this change. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.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.
Summary
Closes #99.
diffFileanddiffDirinvoke delta with--max-line-length=<width>, which is the truncation flag — not a wrap hint. Combined with delta's default--wrap-max-lines=2, any source line longer than roughly two viewport widths got silently dropped in side-by-side mode. In unified mode (where delta does not wrap at all) the long line then hit the post-processing truncation in thediffContentMsghandler, which used an empty tail ("") and clipped without any visible signal.The reporter pointed at both spots in the original issue — both the delta args and the post-processing pass.
Fix
Two changes, both in
pkg/ui/panes/diffviewer/diffviewer.go:Both
diffFileanddiffDir— replace--max-line-length=<width>with--max-line-length=0(disable truncation) and add--wrap-max-lines=unlimited(let delta wrap as many times as needed). Side-by-side mode now wraps long lines all the way through instead of stopping at the second wrap.diffContentMsghandler — change theansi.Truncatetail from""to…. Unified mode (where delta does not wrap) at least surfaces a visible cut-off marker instead of vanishing the remainder.Verification
Local repro with the canonical "very long line" diff at
-w=80:…tailVerified the args delta receives by running them directly:
Existing
pkg/ui/panes/diffviewertest suite passes:The pre-existing
TestSearchResultsRenderWhenFileTreeIsHidden,TestBuildFullFileTree, andTestCollapseTreefailures onmainare unrelated lipgloss-styling drift and are not touched by this PR.Notes on scope
sto switch to side-by-side. Happy to send a follow-up that adds horizontal scroll to the viewport if that's wanted, but kept this PR focused on the bug as filed.--wrap-max-lines=unlimitedvalue is delta's documented sentinel ("a value ofunlimitedmeans a line will be wrapped as many times as required").Credit to @fgrehm for the report and the precise line references in the issue.