Status: resolved · Related: Rust Lossless Syntax and Patches

Problem

CodeMirror’s external replacement diff compares UTF-16 code units. A common prefix or suffix could end inside a supplementary-plane character. Changing 𐐀 to 𐐁 produced from=4/to=5 with a lone low surrogate as the inserted text. Rust cannot deserialize that string or address that position as a scalar boundary, so its mirror could become stale.

Options

approachproscons
AReplace every byte on each Workspace updateavoids the splitloses useful minimal-diff selection mapping
BWiden the changed region over surrogate pairs and CRLFvalid protocol and minimal surrounding changesexplicit boundary handling

Measurements

A direct probe of the committed CodeMirror bundle reproduced the lone-surrogate splice. The structural browser suite now checks both prefix and suffix surrogate boundaries and renames supplementary-plane Rust identifiers through the real graph, remote planner, editor and save path.

Decision

B. Workspace replacements remain one isolated undo entry; this also prevents a graph move from merging with recent user typing. The TypeScript source and rebuilt bundle are committed together.

Lesson

UTF-16 offsets and valid Unicode strings are separate requirements. A minimal diff must respect complete scalar values at both ends before crossing the Rust/JS boundary.