Use cursor position instead of error-prone autocompletion detection

Change-Id: Id93f5ba4d63bff00835ad7738550851e94fcbf7c
This commit is contained in:
SpiritCroc 2022-11-19 15:49:59 +01:00
parent 20081e8806
commit a8ac1ebc60
1 changed files with 6 additions and 0 deletions

View File

@ -184,10 +184,13 @@ class AutoCompleter @AssistedInject constructor(
}
// Detect next word separator
/*
var endIndex = editable.indexOf(" ", startIndex)
if (endIndex == -1) {
endIndex = editable.length
}
*/
val endIndex = editText.selectionEnd
// Replace the word by its completion
editable.delete(startIndex, endIndex)
@ -227,10 +230,13 @@ class AutoCompleter @AssistedInject constructor(
}
// Detect next word separator
/*
var endIndex = editable.indexOfAny(listOf(" ", "\n"), startIndex)
if (endIndex == -1) {
endIndex = editable.length
}
*/
val endIndex = editText.selectionEnd
// Replace the word by its completion
val displayName = matrixItem.getBestName()