Repository navigation
Windows: fix UTF-16 IME cursor offsets around surrogate pairs - #4772
Merged
kchibisov merged 4 commits intoOct 21, 2026
Merged
Conversation
Convert GCS_CURSORPOS code units to UTF-8 byte offsets instead of counting Unicode scalar values. Preserve negative-result handling and clause selection; add regression coverage and a changelog entry.
kchibisov
requested changes
Oct 20, 2026
kchibisov
left a comment
Member
There was a problem hiding this comment.
You can use utf16_to_utf8_offset that is present on appkit(by copy it or putting into winit-common).
Move the existing AppKit conversion into winit-common::text and use it from both backends. Move both backends' conversion regression tests alongside the shared helper. Validation: all eight shared tests pass on Linux; the common library compiles with warnings denied. Native backend builds and nightly formatting have not been run.
Contributor
Author
|
Moved to widget-common , Windows and macOS both share |
kchibisov
approved these changes
Oct 21, 2026
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.
GCS_CURSORPOS counts UTF-16 units, but the Windows fallback counts Rust chars. For a😀b, offset 3 currently becomes byte 6 instead of 5.
Convert using UTF-16 units, round split-surrogate positions down, and clamp oversized offsets. Negative IMM results and clause selection are unchanged. Includes regression tests and a changelog entry.
Related: #4596 fixed the macOS conversion; #4201 fixed Windows clause attributes; #4746 handles a missing cursor-position flag. Neither Windows PR fixes this conversion.
Validation on Windows x64: both new tests fail with the old calculation and pass with the fix.