Count GPUI editor positions in UTF-16 code units like ProseMirror - #7538
Closed
devin-ai-integration[bot] wants to merge 9 commits into
Closed
devin-ai-integration[bot] wants to merge 9 commits into
devin-ai-integration[bot] wants to merge 9 commits into
Conversation
Co-Authored-By: John <john@fastrepl.com>
Co-Authored-By: John <john@fastrepl.com>
Contributor
Author
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
…p-fixtures' into fix/1789066022-pm-utf16-positions
…_slice Co-Authored-By: John <john@fastrepl.com>
… the preceding one Co-Authored-By: John <john@fastrepl.com>
…89066022-pm-utf16-positions
…p-fixtures' into fix/1789066022-pm-utf16-positions
…p-fixtures' into fix/1789066022-pm-utf16-positions
…p-fixtures' into fix/1789066022-pm-utf16-positions
Contributor
Author
|
Superseded by the consolidated GPUI migration PR #7655, which lands this stack in one change on current |
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.
Summary
Problem: The round-trip harness (#7537) found that the GPUI ProseMirror port sizes text nodes in Unicode scalar values, while ProseMirror uses JS string length (UTF-16 code units). Any position exchanged with web-authored data — paste fixture offsets, comment anchor
fromHint/toHint, future collaborative positions — is off by one per astral character (emoji, some CJK extension B).Fix:
pm/node.rsnode_size/cutnow count and slice by UTF-16 units (utf16_len,utf16_slice; a mid-surrogate index — which JS would express as a lone surrogate — clamps to the containing Rust char), andpaste.rsposition/caretconvert byte offsets ↔ UTF-16 units instead of chars.model.rsstays byte-based internally as before.basic-unicodeandmarkdown-tableare removed from the harness'sKNOWN_DIVERGENCES, so the web fixtures now assertnodeSizeequality for them.Stacked on #7537 (base branch is that PR's branch).
Verification
ubuntu-24.04 CI-equivalent container:
cargo test --locked -p desktop-gpui editor(70 passed, incl. paste.gen.json fixtures, roundtrip, new astral-text tests for sizes/cuts/resolve/caret)cargo test --locked -p desktop-gpui(466 passed)cargo clippy --locked -p desktop-gpui --all-targets --no-deps -- -D warningsrustfmt --edition 2024on changed filesLink to Devin session: https://app.devin.ai/sessions/f83ed73d85c648fcbdbd041cd4f15720
Open in Devin Desktop: https://app.devin.ai/desktop/session/f83ed73d85c648fcbdbd041cd4f15720?variant=devin
Requested by: @ComputelessComputer