File tree Expand file tree Collapse file tree 1 file changed +8
-5
lines changed
compose/ui/ui/src/uikitMain/kotlin/androidx/compose/ui/platform Expand file tree Collapse file tree 1 file changed +8
-5
lines changed Original file line number Diff line number Diff line change @@ -28,6 +28,7 @@ import androidx.compose.ui.scene.ComposeSceneFocusManager
28
28
import androidx.compose.ui.text.TextLayoutResult
29
29
import androidx.compose.ui.text.TextRange
30
30
import androidx.compose.ui.text.input.CommitTextCommand
31
+ import androidx.compose.ui.text.input.DeleteSurroundingTextCommand
31
32
import androidx.compose.ui.text.input.EditCommand
32
33
import androidx.compose.ui.text.input.EditProcessor
33
34
import androidx.compose.ui.text.input.FinishComposingTextCommand
@@ -478,11 +479,13 @@ internal class UIKitTextInputService(
478
479
* https://developer.apple.com/documentation/uikit/uikeyinput/1614572-deletebackward
479
480
*/
480
481
override fun deleteBackward () {
481
- // Before this function calls, iOS changes selection in setSelectedTextRange.
482
- // All needed characters should be already selected, and we can just remove them.
483
- sendEditCommand(
484
- CommitTextCommand (" " , 0 )
485
- )
482
+ val deleteCommand =
483
+ if (_tempCurrentInputSession ?.toTextFieldValue()?.selection?.collapsed == true ) {
484
+ DeleteSurroundingTextCommand (lengthBeforeCursor = 1 , lengthAfterCursor = 0 )
485
+ } else {
486
+ CommitTextCommand (" " , 0 )
487
+ }
488
+ sendEditCommand(deleteCommand)
486
489
}
487
490
488
491
/* *
You can’t perform that action at this time.
0 commit comments