Skip to main content

pack_diff_context

Function pack_diff_context 

Source
pub fn pack_diff_context(
    files: &[DiffContextFile<'_>],
    options: DiffContextOptions,
) -> PackedDiffContext
Expand description

Pack file-level diff records into a deterministic context block.

The algorithm is intentionally small:

  1. Sort records by mode-specific priority, using relevance and patch size.
  2. Include full file patches while they fit the optional character budget.
  3. When a high-priority file does not fit, include a compact patch made of file/hunk headers, changed lines, and adjacent context lines.
  4. Return summaries for deleted, omitted, empty, and truncated records.