pub struct RunTextChange {
pub run: u32,
pub start: u32,
pub end: u32,
pub inserted: u32,
}Fields§
§run: u32The run (GraphemeClusterId::source_run) whose text changed.
start: u32First changed byte of the old text.
end: u32One past the last changed byte of the old text (== start for a pure
insert).
inserted: u32How many bytes replaced start..end.
Implementations§
Source§impl RunTextChange
impl RunTextChange
Sourcepub fn between(run: u32, old: &str, new: &str) -> Option<Self>
pub fn between(run: u32, old: &str, new: &str) -> Option<Self>
The smallest change between two versions of one run’s text: the common
prefix and the common suffix are unchanged, what lies between was
replaced. None when the texts are identical.
Byte-level, then backed off to char boundaries on BOTH sides so a
change never starts or ends inside a multi-byte character. When the
inserted text repeats its neighbour (aa -> aaa) the position is
ambiguous by nature; the prefix wins, which puts the change AFTER the
existing copy - the only carets that can tell the difference sit
between identical characters.
Sourcepub fn transform(&self, byte: u32) -> u32
pub fn transform(&self, byte: u32) -> u32
Where a caret that sat at byte of the OLD text sits in the new one.
The user’s rule (2026-09-03): a caret is anchored at a LOGICAL position, so a change entirely before it shifts it by the delta, a change entirely after it leaves it alone, and a change that spans it collapses it to the change’s start - the only position that still exists. A caret AT a pure insert’s position counts as after it: it is attached to the character that follows, and that character moved.
Trait Implementations§
Source§impl Clone for RunTextChange
impl Clone for RunTextChange
Source§fn clone(&self) -> RunTextChange
fn clone(&self) -> RunTextChange
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more