Skip to main content

apply_edits

Function apply_edits 

Source
pub fn apply_edits(
    content: &str,
    edits: &[Edit],
    path: &str,
) -> Result<(String, String)>
Expand description

Apply a set of edits to LF-normalized content. Each old_text is matched against the original (not incrementally); edits must be unique and non-overlapping. As a fallback, when an exact match fails the search retries in fuzzy-normalized space (mirrors pi’s applyEditsToNormalizedContent). If any edit needs fuzzy matching, all edits are applied in that space and then overlaid onto the original line-by-line so untouched lines keep their bytes. Returns (base, new) for diffing.