@@ -256,7 +256,8 @@ class KeyboardActionListenerImpl(private val latinIME: LatinIME, private val inp
256256 private fun onMoveCursorHorizontally (rawSteps : Int ): Boolean {
257257 if (rawSteps == 0 ) return false
258258 // for RTL languages we want to invert pointer movement
259- val steps = if (RichInputMethodManager .getInstance().currentSubtype.isRtlSubtype) - rawSteps else rawSteps
259+ val rtl = RichInputMethodManager .getInstance().currentSubtype.isRtlSubtype
260+ val steps = if (rtl) - rawSteps else rawSteps
260261 val moveSteps: Int
261262 if (steps < 0 ) {
262263 val text = connection.getTextBeforeCursor(- steps * 4 , 0 ) ? : return false
@@ -265,7 +266,8 @@ class KeyboardActionListenerImpl(private val latinIME: LatinIME, private val inp
265266 // some apps don't return any text via input connection, and the cursor can't be moved
266267 // we fall back to virtually pressing the left/right key one or more times instead
267268 repeat(- steps) {
268- onCodeInput(KeyCode .ARROW_LEFT , Constants .NOT_A_COORDINATE , Constants .NOT_A_COORDINATE , false )
269+ onCodeInput(if (rtl) KeyCode .ARROW_RIGHT else KeyCode .ARROW_LEFT , Constants .NOT_A_COORDINATE ,
270+ Constants .NOT_A_COORDINATE , false )
269271 }
270272 if (text.isNotEmpty()) {
271273 gestureMoveBackHaptics()
@@ -280,7 +282,8 @@ class KeyboardActionListenerImpl(private val latinIME: LatinIME, private val inp
280282 // some apps don't return any text via input connection, and the cursor can't be moved
281283 // we fall back to virtually pressing the left/right key one or more times instead
282284 repeat(steps) {
283- onCodeInput(KeyCode .ARROW_RIGHT , Constants .NOT_A_COORDINATE , Constants .NOT_A_COORDINATE , false )
285+ onCodeInput(if (rtl) KeyCode .ARROW_LEFT else KeyCode .ARROW_RIGHT , Constants .NOT_A_COORDINATE ,
286+ Constants .NOT_A_COORDINATE , false )
284287 }
285288 if (text.isNotEmpty()) {
286289 gestureMoveForwardHaptics(true )
0 commit comments