From db96122787a57632136566e2448c21aa96879955 Mon Sep 17 00:00:00 2001 From: Mohammadinamul Sheik Date: Mon, 13 Apr 2015 16:30:22 -0700 Subject: Fix the NPE on selection string on unlearnWord Bug: 20150386 Change-Id: I2ed69aba7b1fdaba1e2ac07b8218a265dfe23e09 --- java/src/com/android/inputmethod/latin/inputlogic/InputLogic.java | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'java/src/com/android/inputmethod/latin/inputlogic/InputLogic.java') diff --git a/java/src/com/android/inputmethod/latin/inputlogic/InputLogic.java b/java/src/com/android/inputmethod/latin/inputlogic/InputLogic.java index 4bee94ad4..324ae3a19 100644 --- a/java/src/com/android/inputmethod/latin/inputlogic/InputLogic.java +++ b/java/src/com/android/inputmethod/latin/inputlogic/InputLogic.java @@ -1089,8 +1089,11 @@ public final class InputLogic { // If there is a selection, remove it. // We also need to unlearn the selected text. final CharSequence selection = mConnection.getSelectedText(0 /* 0 for no styles */); - unlearnWord(selection.toString(), inputTransaction.mSettingsValues, - Constants.EVENT_BACKSPACE); + if (!TextUtils.isEmpty(selection)) { + unlearnWord(selection.toString(), inputTransaction.mSettingsValues, + Constants.EVENT_BACKSPACE); + hasUnlearnedWordBeingDeleted = true; + } final int numCharsDeleted = mConnection.getExpectedSelectionEnd() - mConnection.getExpectedSelectionStart(); mConnection.setSelection(mConnection.getExpectedSelectionEnd(), -- cgit v1.2.3-83-g751a