Skip to main content

Module edit_diff

Module edit_diff 

Source
Expand description

Pure edit matching and diff helpers for the edit tool.

Ports .references/pi/packages/coding-agent/src/core/tools/edit-diff.ts. Matching runs against the original LF-normalized file; multi-edits apply in reverse offset order. Fuzzy matches preserve untouched original line bytes.

Structs§

AppliedEditsResult
Result of applying edits to LF-normalized content.
DiffStringResult
Display-oriented diff result.
Edit
One exact-text replacement.

Enums§

LineEnding
Line ending detected from file content (first occurrence wins).

Functions§

apply_edits_to_normalized_content
Apply one or more exact-text replacements to LF-normalized content.
detect_line_ending
Detect line ending from the first newline occurrence.
generate_diff_string
Generate a display-oriented numbered diff with context collapse.
generate_unified_patch
Generate a standard contextual unified patch.
normalize_for_fuzzy_match
Normalize text for fuzzy matching (NFKC, trimEnd, quotes, dashes, spaces).
normalize_to_lf
Normalize \r\n and bare \r to \n.
restore_line_endings
Restore LF content to the original line ending style.
strip_bom
Strip a leading UTF-8 BOM, returning (bom, text_without_bom).