Skip to content

Commit 0ece323

Browse files
Comprehensive delimiter for deleting last word. (#206)
Using the "s" regex metacharacter to better match whitespace characters. Line feeds and carriage returns are currently not being considered, so deleteLastWord() can delete multiple words on multiple lines. E.g. on the first word of a subsequent paragraph. Co-authored-by: Dessalines <dessalines@users.noreply.github.com>
1 parent 95bc2c4 commit 0ece323

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

  • app/src/main/java/com/dessalines/thumbkey/utils

app/src/main/java/com/dessalines/thumbkey/utils/Utils.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -348,7 +348,7 @@ fun deleteLastWord(ime: IMEService) {
348348

349349
val trimmedLength = lastWords?.length?.minus(lastWords.trimmedLength()) ?: 0
350350
val trimmed = lastWords?.trim()
351-
val lastWordLength = trimmed?.split(" ")?.lastOrNull()?.length ?: 1
351+
val lastWordLength = trimmed?.split("\\s".toRegex())?.lastOrNull()?.length ?: 1
352352
val minDelete = if (lastWordLength > 0) {
353353
lastWordLength + trimmedLength
354354
} else {

0 commit comments

Comments
 (0)