Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit db961227 authored by Mohammadinamul Sheik's avatar Mohammadinamul Sheik
Browse files

Fix the NPE on selection string on unlearnWord

Bug: 20150386
Change-Id: I2ed69aba7b1fdaba1e2ac07b8218a265dfe23e09
parent 40f0f61b
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -48,6 +48,7 @@ import com.android.inputmethod.latin.utils.SpannableStringUtils;
import com.android.inputmethod.latin.utils.TextRange;

import javax.annotation.Nonnull;
import javax.annotation.Nullable;

/**
 * Enrichment class for InputConnection to simplify interaction and add functionality.
@@ -288,6 +289,7 @@ public final class RichInputConnection implements PrivateCommandPerformer {
        }
    }

    @Nullable
    public CharSequence getSelectedText(final int flags) {
        return isConnected() ?  mIC.getSelectedText(flags) : null;
    }
+5 −2
Original line number Diff line number Diff line
@@ -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 */);
                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(),