pub fn shift_runs_for_replace(
runs: &mut Vec<FormatRun>,
byte_start: u32,
byte_end: u32,
replacement_bytes: u32,
policy: ReplaceFormatPolicy,
) -> Result<(), FormatRunError>Expand description
Apply a “replace byte range [byte_start..byte_end) with replacement_bytes bytes”
mutation to a block’s runs, choosing explicitly what the replacement wears.
This is the one edit where the old delete-then-insert composition quietly lost a
writer’s formatting: replacing Auré**lien** deletes both runs under the range and
then lets the replacement inherit whatever preceded it, so the bold is gone. That
behaviour is still available — and is still the default — but it is now a decision
(ReplaceFormatPolicy) rather than an accident of two functions being called in
sequence.
Additive by design: shift_runs_for_delete / shift_runs_for_insert are untouched,
because 13 other call sites across delete/insert/paste depend on their exact
behaviour. ReplaceFormatPolicy::InheritPreceding is implemented by calling that
very composition, so the default cannot drift away from what shipped.
Returns Err rather than corrupting the block if the range is inverted or the
re-splice would violate the run invariants — see FormatRunError.