Skip to main content

Module text_diff

Module text_diff 

Source
Expand description

Line-level text diffing for long text properties.

Produces structured diffs with context lines for human-readable comparison of instructions, descriptions, and other long text fields. Supports word-level highlighting within modified paragraphs.

Structs§

TextDiffHunk
A group of contiguous diff lines with surrounding context.
TextDiffResult
Result of a line-level text diff.
WordSegment
A segment of a word-level diff within a single line.

Enums§

DiffLine
A single line in a text diff.
WordSegmentKind
Whether a word segment is unchanged or changed.

Constants§

CONTEXT_TRUNCATE_LEN
Maximum display length for context lines before truncation.
LONG_TEXT_THRESHOLD
Minimum string length to trigger line-level diffing.

Functions§

diff_text
Compute a line-level diff between two strings.
diff_words
Compute word-level diff segments between two strings.
is_long_text
Returns true if the string is long enough or multi-line to warrant line-level diffing instead of inline comparison.
normalize_for_diff
Normalize text for more readable line-level diffs.
truncate_context
Truncate a string to approximately max_len characters with " ... " in the middle.