Skip to main content

Module diff_doc

Module diff_doc 

Source
Expand description

Unified-diff parsing + whitespace/formatting filters.

Pure data model — no terminal I/O, no ratatui rendering. Consumed by the git TUI overlay (rendering wired in a follow-up task).

Structs§

DiffDocument
One parsed unified-diff document: zero or more DiffFile entries.
DiffFile
One file in a DiffDocument.
DiffLine
One line inside a Hunk. The text DOES NOT include the leading +/-/ prefix character.
Hunk
One hunk header (@@ -old,count +new,count @@) plus its lines.

Enums§

DiffLineKind
Role of a single DiffLine.
DiffViewMode
View mode for the rendered diff. Orthogonal to WhitespaceMode — both live on the same DiffDocument and can be applied independently.
WhitespaceMode
Whitespace / formatting filter mode for filter_whitespace.

Functions§

filter_whitespace
Filter a DiffDocument by WhitespaceMode. Returns a new document; hunks that survive filtering keep their text but may have their line kinds rewritten (Added/Removed → Context). Hunks that are fully demoted keep all their lines — only the kind changes.
parse_unified_diff
Parse a git diff output into a DiffDocument.