Hi, I’m trying to better understand the Yjs internals and have a question about why a Y.Text origin (or originRight) might be set to the ID of an Item that doesn’t actually exist.
Given the following:
const yText = doc.getText("someText");
yText.insert(0, "abd");
yText.insert(2, "c");
const update = Y.decodeUpdate(Y.encodeStateAsUpdate(doc)));
update
ends up with a (simplified) array of items like this:
[
{
id: { client: 2487576965, clock: 0 },
content: { str: "ab" },
},
{
id: { client: 2487576965, clock: 2 },
content: { str: "d" },
length: 1,
origin: { client: 2487576965, clock: 1 }, // 👈 No item with this ID exists--what's going on?
},
{
id: { client: 2487576965, clock: 3 },
content: { str: "c" },
length: 1,
origin: { client: 2487576965, clock: 1 }, // 👈 No item with this ID exists--what's going on?
rightOrigin: { client: 2487576965, clock: 2 },
},
]
Why do the 2nd and 3rd items reference an item (origin, originRight) that doesn’t actually exist? Is this just how splits work–like maybe the “split” itself becomes a kind of invisible operation that caused the clock/counter to increment?
Thank you!