Skip to content

Commit

Permalink
Update SimpleKeyboardIME.kt fun hastextbeforecursor
Browse files Browse the repository at this point in the history
  • Loading branch information
KesharwaniArpita authored Oct 19, 2024
1 parent 3bd1bb1 commit e18a51b
Showing 1 changed file with 2 additions and 12 deletions.
14 changes: 2 additions & 12 deletions app/src/main/java/be/scri/services/SimpleKeyboardIME.kt
Original file line number Diff line number Diff line change
Expand Up @@ -65,18 +65,8 @@ abstract class SimpleKeyboardIME :

override fun hasTextBeforeCursor(): Boolean {
val inputConnection = currentInputConnection ?: return false
val textBeforeCursor = inputConnection.getTextBeforeCursor(Int.MAX_VALUE, 0)

// Initialize result variable
var hasText = false

if (!textBeforeCursor.isNullOrBlank()) {
val trimmedText = textBeforeCursor.trim()
val lastChar = trimmedText.lastOrNull()
hasText = lastChar != '.'
}

return hasText // Return the final result
val textBeforeCursor = inputConnection.getTextBeforeCursor(Int.MAX_VALUE, 0).orEmpty().trim()
return textBeforeCursor.isNotEmpty() && textBeforeCursor.lastOrNull() != '.'
}

override fun commitPeriodAfterSpace() {
Expand Down

0 comments on commit e18a51b

Please sign in to comment.