Skip to main content

chunk_diff

Function chunk_diff 

Source
pub fn chunk_diff(content: &str) -> (Cow<'_, str>, bool, usize)
Expand description

Chunks a large diff by preserving the first N and last N lines.

When the diff exceeds head_lines + tail_lines, the middle section is replaced with a placeholder. Returns the original content unchanged (as a borrowed reference) when no truncation is needed, avoiding allocation.

Uses DEFAULT_CHUNK_HEAD_LINES and DEFAULT_CHUNK_TAIL_LINES as defaults. Pass explicit values via chunk_diff_with_params when the caller has per-provider or user-configured thresholds.

§Arguments

  • content — The full diff content.

§Returns

A tuple of (chunked_content, was_truncated, removed_lines).