1
0
Fork 0

fixed a crash when holding Backspace to delete generated word suggestions on slower devices

This commit is contained in:
sspanak 2024-06-20 17:57:30 +03:00 committed by Dimo Karaivanov
parent e61bf9b652
commit b833197f51

View file

@ -173,6 +173,12 @@ public class Predictions {
private ArrayList<String> generateWordVariations(String baseWord) {
ArrayList<String> generatedWords = new ArrayList<>();
// This function is called from async context, so by the time it is executed, the digit sequence
// might have been deleted. But in this case, it makes no sense to generate suggestions.
if (digitSequence.isEmpty()) {
return generatedWords;
}
// Make sure the displayed word and the digit sequence, we will be generating suggestions from,
// have the same length, to prevent visual discrepancies.
baseWord = (baseWord != null && !baseWord.isEmpty()) ? baseWord.substring(0, Math.min(digitSequence.length() - 1, baseWord.length())) : "";