Documentation
¶
Overview ¶
Package worddiff provides intra-line word-diff algorithms and a shared text-range highlight insertion engine. It owns tokenization, LCS computation, byte-offset range building, similarity gating, and line pairing for add/remove diff blocks.
The public API is exposed as methods on the stateless Differ type, enabling consumer-side interface wrapping in the ui package (same pattern as style.SGR).
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Differ ¶
type Differ struct{}
Differ provides intra-line word-diff algorithms and highlight marker insertion. stateless — the receiver carries no mutable state. exists to group related methods under a type for consumer-side interface wrapping (same pattern as style.SGR).
func New ¶
func New() *Differ
New returns a Differ. the constructor exists for consistency with the DI pattern (main.go calls worddiff.New() and injects into ModelConfig).
func (*Differ) ComputeIntraRanges ¶
ComputeIntraRanges computes changed byte-offset ranges for a pair of minus/plus lines. returns ranges for the minus line and plus line respectively. returns nil ranges if either line is empty, exceeds maxLineLenForDiff, or fails the similarity gate (< 30% common non-whitespace tokens).
func (*Differ) InsertHighlightMarkers ¶
InsertHighlightMarkers walks the string inserting hlOn/hlOff ANSI sequences at match positions, skipping over existing ANSI escape sequences to preserve them. tracks background ANSI state so that match-end restores to the correct bg (e.g. word-diff bg) rather than always using the static hlOff (line bg). when the input has no bg sequences (word-diff caller), restoreBg stays at hlOff and behavior is unchanged.