fixed a crash when holding Backspace to delete generated word suggestions on slower devices
This commit is contained in:
parent
e61bf9b652
commit
b833197f51
1 changed files with 6 additions and 0 deletions
|
|
@ -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())) : "";
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue