Skip to main content

fetch_file_hunks

Function fetch_file_hunks 

Source
async fn fetch_file_hunks(
    cwd: &Path,
    ref_spec: &str,
    path: &str,
    budget: Duration,
) -> FileScanOutcome
Expand description

Fetch one file’s hunks for the overlay, pinning at PINNED_CONTEXT_LINES so the returned hunks carry enough context for in-memory expansion. The -- separator keeps a --foo path from being read as a flag.

A file whose pinned fetch trips the oversize cap falls back to a bounded FALLBACK_CONTEXT_LINES diff and is flagged oversize (it renders but can’t expand); if even that is oversize (a huge fully- rewritten file) it keeps empty hunks and the flag. Either way it stays Ok, so one big file never flips the scope-wide scanner_ok.

ref_spec is the already-resolved diff range from diff_ref_spec (e.g. HEAD, or main...HEAD); callers pre-resolve it so the per-file and top-level scans agree.