Skip to main content

Crate vtcode_diff

Crate vtcode_diff 

Source
Expand description

Bounded structured text diffs and renderer-neutral preview rows.

The presentation architecture and underlying ideas (unified and side-by-side terminal previews with intraline emphasis) were informed by OpenAI Codex (Apache-2.0). This crate is an independent implementation for VT Code; no Codex source code was copied.

Structs§

AnsiDiffPalette
Caller-supplied foreground styles for ANSI output.
DiffBundle
A diff rendered with both structured hunks and formatted text.
DiffCell
One side of a semantic preview row.
DiffChangeCounts
Aggregate addition/deletion counts retained for compatibility.
DiffDisplayLine
A semantic legacy display line.
DiffDocument
A complete renderer-independent diff.
DiffHunk
A diff hunk with old/new ranges and semantic lines.
DiffLine
A source line and its old/new positions.
DiffOptions
Options controlling diff generation.
DiffRow
A renderer-neutral row, optionally containing paired side-by-side cells.
DiffSegment
One independently styled content segment.
DiffStats
Aggregate statistics for a complete document.
IntralineRange
Intraline byte range, always aligned to UTF-8 boundaries.
LayoutOptions
Width and bounded-excerpt options for semantic layout.
ParseDiffError
Error returned for malformed unified diff input.
SideBySideRow
One paired row in the compatibility side-by-side model.

Enums§

Chunk
A contiguous borrowed character-level diff chunk.
DiffAlgorithm
Algorithms suitable for interactive diff previews.
DiffDisplayKind
Semantic role used by legacy preview consumers.
DiffLayout
Requested preview layout.
DiffLineKind
The semantic role of a line inside a hunk.
DiffRowKind
Semantic role for a renderer-neutral row.

Constants§

DIFF_MIN_BODY_WIDTH_WITH_GUTTER
Minimum source width retained when the unified line gutter is visible.
DIFF_MIN_SIDE_BY_SIDE_WIDTH
Minimum content width for the paired old/new preview.

Functions§

annotate_word_level_diffs
Adds byte-safe intraline ranges to consecutive deletion/addition groups.
bounded_display_lines
Returns a bounded head/tail excerpt of semantic display lines.
compute_diff
Computes a structured diff and passes non-empty hunks to a formatter.
compute_diff_chunks
Computes a character-level diff with adjacent chunks coalesced.
count_diff_changes
Counts additions and deletions in structured hunks.
diff_display_line_number_width
Computes the clamped line-number gutter width.
diff_gutter_fits
Whether a unified diff can keep its marker, line number, and separator without starving the source body.
diff_gutter_width
Width consumed by a unified diff gutter after the line-number field.
diff_layout_width
Width to pass to semantic unified layout when the renderer hides its visible gutter.
diff_side_by_side_fits
Whether a measured width can support the paired old/new preview.
display_lines_from_hunks
Converts hunks to semantic display lines and bounded intraline ranges.
display_lines_from_unified_diff
Parses unified text into display lines, retaining metadata lines.
format_hunk_header
Formats a git-compatible @@ -old +new @@ hunk header.
format_numbered_unified_diff
Formats a numbered unified diff without ANSI color.
format_unified_diff
Formats a structured diff as plain unified text.
format_unified_hunks
Formats precomputed hunks as plain unified text.
layout_display_lines
Lays out precomputed display lines without repeating intraline analysis.
render_ansi_rows
Renders semantic rows as ANSI lines.
side_by_side_rows
Pairs deletions and additions for side-by-side presentation.
to_ratatui_lines
Converts semantic rows to unstyled Ratatui lines for caller styling.
word_level_changed_ranges
Computes byte-safe word-level changed ranges for a line pair.

Type Aliases§

WordChangedRanges
Intra-line highlight ranges retained for compatibility.