Fix possible crash in autocompletion

https://github.com/SchildiChat/SchildiChat-android-rageshakes/issues/1129

Change-Id: If8514bdcd39e6477a938decf59d2380466898b23
This commit is contained in:
SpiritCroc 2023-08-02 20:33:04 +02:00
parent 6972f08b96
commit 1bc97e0aba

View File

@ -305,7 +305,14 @@ class AutoCompleter @AssistedInject constructor(
endIndex = editable.length
}
*/
val endIndex = editText.selectionEnd
var endIndex = editText.selectionEnd
if (endIndex == -1) {
endIndex = editable.length
} else if (endIndex < startIndex) {
val tmp = startIndex
startIndex = endIndex
endIndex = tmp
}
// Replace the word by its completion
val displayName = matrixItem.getBestName()