Expand description
Line-anchored literal block matching, shared by ct-search, ct-view,
and ct-edit.
A multi-line pattern matches as a block: a find block of K lines matches
K consecutive source lines exactly, byte-for-byte, leading and trailing
whitespace significant. When a block fails to match, nearest_miss
reports the best partial alignment — the candidate with the longest
matching prefix and the first diverging line — so the author sees why
the anchor missed (whitespace drift, a comment edit, an already-applied
change) without bisecting by hand.
Structs§
- Nearest
Miss - The best partial alignment of a block that did not match.
Functions§
- edit_
blocks - Replace every non-overlapping occurrence of
blockincontentwithreplacementlines, preserving every untouched byte (including a missing final newline). An emptyreplacementdeletes the matched lines entirely. Returns the new content, the occurrence count, and the changed sites (lineis the block’s 1-based start;before/afterare newline-joined). - find_
starts - Find every non-overlapping occurrence of
blockinlines, scanning forward. Returns the 0-based start indices. - nearest_
miss - Report the best partial alignment of an unmatched
blockagainstlines: the start with the longest run of matching leading block lines (ties go to the earliest). When no line equals the block’s first line at all, falls back to a whitespace-insensitive scan of that first line, so indentation drift — the most common anchor failure — is still diagnosed.