Cursor is a stable position representation in the doc.
When expressing the position of a cursor, using "index" can be unstable
because the cursor's position may change due to other deletions and insertions,
requiring updates with each edit. To stably represent a position or range within
a list structure, we can utilize the ID of each item/character on List CRDT or
Text CRDT for expression.
Loro optimizes State metadata by not storing the IDs of deleted elements. This
approach complicates tracking cursors since they rely on these IDs. The solution
recalculates position by replaying relevant history to update cursors
accurately. To minimize the performance impact of history replay, the system
updates cursor info to reference only the IDs of currently present elements,
thereby reducing the need for replay.
Cursor is a stable position representation in the doc. When expressing the position of a cursor, using "index" can be unstable because the cursor's position may change due to other deletions and insertions, requiring updates with each edit. To stably represent a position or range within a list structure, we can utilize the ID of each item/character on List CRDT or Text CRDT for expression.
Loro optimizes State metadata by not storing the IDs of deleted elements. This approach complicates tracking cursors since they rely on these IDs. The solution recalculates position by replaying relevant history to update cursors accurately. To minimize the performance impact of history replay, the system updates cursor info to reference only the IDs of currently present elements, thereby reducing the need for replay.
Example