Repository navigation
Fix selection for transformed text with Native Text Input - #3526
Andrei Salavei (ASalavei) merged 11 commits into
Conversation
|
Could you explain why Is it just to put |
Yes. The issue that the |
Do we need a public API? If not, could we just use |
Yes, we need this API to be available in ui:ui. The |
| /** | ||
| * Maps a [range] in the original text to the corresponding range in the transformed text. | ||
| */ | ||
| fun mapToTransformed(range: TextRange): TextRange |
There was a problem hiding this comment.
Would it not be more convenient to map indices rather than ranges?
There was a problem hiding this comment.
I choose ranges because they provide more universal API then indices and add more variety to the selection capabilities. When developing the feature, I met cases where range selection work different then individual indices and includes not only extra symbols before the original text characters, but also symbols after it.
Currently, aforementioned capabilities are are unused and we indeed falling back to the individual indices API to match Android behavior, but I would keep it like this in case we'll fase any issues.
# Conflicts: # compose/ui/ui/src/iosMain/kotlin/androidx/compose/ui/text/input/ComposeTextInputConnection.ios.kt # compose/ui/ui/src/iosMain/kotlin/androidx/compose/ui/text/input/TextInputConnection.ios.kt
| return null | ||
| } | ||
| if (position > currentTextLayoutResult.multiParagraph.intrinsics.annotatedString.length) { | ||
| val transformedPosition = offsetMapping.mapToTransformed(position) |
There was a problem hiding this comment.
Don't we need transformed range here as well?
There was a problem hiding this comment.
Yes - position in the original text coordinates.
currentTextLayoutResult uses transformed text coordinates, so we have to convert it.
The
UITextInputprotocol uses original text and original selection range to provide to the user corresponding text editing operations. The new parameteroffsetMappingis added in order to provide correct selection layout using theTextLayoutResult- which uses ranges of the transformed text.Introduce
TextEditorOffsetMappingthat provides bidirectional offset mapping between original and transformed text. Add corresponding parameter to theSkikoPlatformTextInputMethodRequest.Update text selection and cursor rects calculation according to the selection offset in transformed text.
Fixes https://youtrack.jetbrains.com/issue/CMP-10073/NITI-OutputTransformation-is-broken-on-iOS-using-the-new-usingNativeTextInput
Release Notes
Fixes - iOS