Conversation
Validate UTF-16 character boundaries and select the complete scalar when creating stable text cursors. Cover cross-peer atoms, remote edits, and native indexing. Fixes loro-dev#1101 Agent: codex-1
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #1101.
LoroText.getCursor()can returnundefinedat the start of an emoji when that character occupies its own text atom. It can also accept a position inside a surrogate pair and anchor it at the preceding boundary.The stable-position lookup now verifies that the queried cursor maps back to the requested index and, for WASM event indices, selects the full UTF-16 width of the character. Native Unicode indexing, cursor sides, and end-of-document behavior are preserved. No public signatures or serialized formats change.
Regression coverage includes mixed non-BMP text, combining sequences, mid-surrogate positions, separate-peer atoms, cursor resolution after remote edits, and native Rust controls. A patch changeset is included; the code comment explains why the index round trip is necessary.
Validation
cargo check -p loro-internalpassed.git diff --checkpasses.Repository-wide formatting and Clippy are not green on the unmodified base with the local Rust 1.98 toolchain (unrelated formatting differences and existing
generic-btreediagnostics). No unrelated formatting or dependency changes are included. WASM package tests used a temporary empty PostCSS configuration to avoid an unrelated configuration in the parent directory; that workaround is not part of this patch.