Repository navigation
Conversation
- DiffStyle gains wrapLongLines and wrapMarker (withWrapLongLines builder) - DiffLineWrapper splits content into word-boundary segments with a configurable continuation marker; DiffMetrics estimates characters per line from available width via GeometryReader + platform fonts - Unified, inline, and side-by-side views render wrapped rows with the marker, dimmed continuation text, and blank line-number gutters - New .wrapLines(_:marker:) modifiers on DiffView/PatchView/PatchesView - Unit tests for the wrapping logic; README documentation
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
Adds an opt-in wrapped lines mode to
JSDiffUIso long diff lines wrap onto multiple visual rows (with a↪continuation marker) instead of being truncated or overflowing.Changes
DiffStyle: newwrapLongLines: Bool = falseandwrapMarker: String = "↪ "options, plus awithWrapLongLines(_:marker:)builder methodDiffLineWrapper(new): word-boundary chunking engine — hard-splits words longer than the limit, consumes break spaces, and accounts for marker width on continuation rows. Also includesDiffMetricsfor estimating characters-per-line from available width using platform monospaced fonts (UIKit/AppKit)DiffWrappedContentView(new): shared view rendering a line as stacked visual rows; continuation rows get the marker, dimmed text, the same background highlight, and blank line-number gutters so alignment is preservedUnifiedDiffView,UnifiedPatchView,InlineDiffLineView, and side-by-side columns measure their own width viaGeometryReaderand thread the wrap limit down.wrapLines(_:)/.wrapLines(_:marker:)modifiers onDiffView,PatchView, andPatchesViewDefault behavior is unchanged (
wrapLongLinesdefaults tofalse).Usage
Implementation note
SwiftUI's
AttributedStringdoesn't support paragraph-level hanging indents, so wrapping is done by pre-splitting into estimated-width segments rather than relying on native text layout. A TextKit-based implementation could replace the estimator later for pixel-perfect wrapping.Testing
swift build✅swift test— all 32 tests pass (including 6 new wrapper tests) ✅