bring back elvis he never hurt nobody

This commit is contained in:
devycarol 2025-03-06 23:43:38 -07:00
parent 32a21092d3
commit fed79abe26

View file

@ -117,16 +117,14 @@ class KeyboardActionListenerImpl(private val latinIME: LatinIME, private val inp
var actualSteps = 0 var actualSteps = 0
// corrected steps to avoid splitting chars belonging to the same codepoint // corrected steps to avoid splitting chars belonging to the same codepoint
if (steps > 0) { if (steps > 0) {
val text = connection.getSelectedText(0) val text = connection.getSelectedText(0) ?: return steps
if (text == null) actualSteps = steps loopOverCodePoints(text) { cp, charCount ->
else loopOverCodePoints(text) { cp, charCount ->
actualSteps += charCount actualSteps += charCount
if (actualSteps >= steps) return actualSteps if (actualSteps >= steps) return actualSteps
} }
} else { } else {
val text = connection.getTextBeforeCursor(-steps * 4, 0) val text = connection.getTextBeforeCursor(-steps * 4, 0) ?: return steps
if (text == null) actualSteps = steps loopOverCodePointsBackwards(text) { cp, charCount ->
else loopOverCodePointsBackwards(text) { cp, charCount ->
actualSteps -= charCount actualSteps -= charCount
if (actualSteps <= steps) return actualSteps if (actualSteps <= steps) return actualSteps
} }