Check for null TextRange in InputLogic.unlearnWordBeingDeleted
Change-Id: Ia0df0ab740c76185f94966f59a74a6ebdd1cffe8
This commit is contained in:
parent
1d5ec6136c
commit
edb2d23802
1 changed files with 9 additions and 4 deletions
|
@ -1094,8 +1094,8 @@ public final class InputLogic {
|
|||
int totalDeletedLength = 1;
|
||||
if (mDeleteCount > Constants.DELETE_ACCELERATE_AT) {
|
||||
// If this is an accelerated (i.e., double) deletion, then we need to
|
||||
// consider unlearning here too because we may have just entered the
|
||||
// previous word, and the next deletion will currupt it.
|
||||
// consider unlearning here because we may have already reached
|
||||
// the previous word, and will lose it after next deletion.
|
||||
hasUnlearnedWordBeingDeleted |= unlearnWordBeingDeleted(
|
||||
inputTransaction.mSettingsValues, currentKeyboardScriptId);
|
||||
sendDownUpKeyEvent(KeyEvent.KEYCODE_DEL);
|
||||
|
@ -1121,8 +1121,8 @@ public final class InputLogic {
|
|||
int totalDeletedLength = lengthToDelete;
|
||||
if (mDeleteCount > Constants.DELETE_ACCELERATE_AT) {
|
||||
// If this is an accelerated (i.e., double) deletion, then we need to
|
||||
// consider unlearning here too because we may have just entered the
|
||||
// previous word, and the next deletion will currupt it.
|
||||
// consider unlearning here because we may have already reached
|
||||
// the previous word, and will lose it after next deletion.
|
||||
hasUnlearnedWordBeingDeleted |= unlearnWordBeingDeleted(
|
||||
inputTransaction.mSettingsValues, currentKeyboardScriptId);
|
||||
final int codePointBeforeCursorToDeleteAgain =
|
||||
|
@ -1166,6 +1166,11 @@ public final class InputLogic {
|
|||
final TextRange range = mConnection.getWordRangeAtCursor(
|
||||
settingsValues.mSpacingAndPunctuations,
|
||||
currentKeyboardScriptId);
|
||||
if (range == null) {
|
||||
// TODO(zivkovic): Check for bad connection before getting this far.
|
||||
// Happens if we don't have an input connection at all.
|
||||
return false;
|
||||
}
|
||||
final String wordBeingDeleted = range.mWord.toString();
|
||||
if (!wordBeingDeleted.isEmpty()) {
|
||||
unlearnWord(wordBeingDeleted, settingsValues,
|
||||
|
|
Loading…
Reference in a new issue