am edb2d238: Check for null TextRange in InputLogic.unlearnWordBeingDeleted

* commit 'edb2d2380214fa3a6d5416cc916f58360214d123':
  Check for null TextRange in InputLogic.unlearnWordBeingDeleted
This commit is contained in:
Tom Ouyang 2015-02-24 20:07:20 +00:00 committed by Android Git Automerger
commit 30a9af899f

View file

@ -1094,8 +1094,8 @@ public final class InputLogic {
int totalDeletedLength = 1; int totalDeletedLength = 1;
if (mDeleteCount > Constants.DELETE_ACCELERATE_AT) { if (mDeleteCount > Constants.DELETE_ACCELERATE_AT) {
// If this is an accelerated (i.e., double) deletion, then we need to // If this is an accelerated (i.e., double) deletion, then we need to
// consider unlearning here too because we may have just entered the // consider unlearning here because we may have already reached
// previous word, and the next deletion will currupt it. // the previous word, and will lose it after next deletion.
hasUnlearnedWordBeingDeleted |= unlearnWordBeingDeleted( hasUnlearnedWordBeingDeleted |= unlearnWordBeingDeleted(
inputTransaction.mSettingsValues, currentKeyboardScriptId); inputTransaction.mSettingsValues, currentKeyboardScriptId);
sendDownUpKeyEvent(KeyEvent.KEYCODE_DEL); sendDownUpKeyEvent(KeyEvent.KEYCODE_DEL);
@ -1121,8 +1121,8 @@ public final class InputLogic {
int totalDeletedLength = lengthToDelete; int totalDeletedLength = lengthToDelete;
if (mDeleteCount > Constants.DELETE_ACCELERATE_AT) { if (mDeleteCount > Constants.DELETE_ACCELERATE_AT) {
// If this is an accelerated (i.e., double) deletion, then we need to // If this is an accelerated (i.e., double) deletion, then we need to
// consider unlearning here too because we may have just entered the // consider unlearning here because we may have already reached
// previous word, and the next deletion will currupt it. // the previous word, and will lose it after next deletion.
hasUnlearnedWordBeingDeleted |= unlearnWordBeingDeleted( hasUnlearnedWordBeingDeleted |= unlearnWordBeingDeleted(
inputTransaction.mSettingsValues, currentKeyboardScriptId); inputTransaction.mSettingsValues, currentKeyboardScriptId);
final int codePointBeforeCursorToDeleteAgain = final int codePointBeforeCursorToDeleteAgain =
@ -1166,6 +1166,11 @@ public final class InputLogic {
final TextRange range = mConnection.getWordRangeAtCursor( final TextRange range = mConnection.getWordRangeAtCursor(
settingsValues.mSpacingAndPunctuations, settingsValues.mSpacingAndPunctuations,
currentKeyboardScriptId); 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(); final String wordBeingDeleted = range.mWord.toString();
if (!wordBeingDeleted.isEmpty()) { if (!wordBeingDeleted.isEmpty()) {
unlearnWord(wordBeingDeleted, settingsValues, unlearnWord(wordBeingDeleted, settingsValues,