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

Commit a200a23a authored by Fabrice Di Meglio's avatar Fabrice Di Meglio Committed by Android (Google) Code Review
Browse files

Merge "Bug 5332065: IOOB in case the suggestionSpan has been removed" into ics-factoryrom

parents 8632561e 14ed50a9
Loading
Loading
Loading
Loading
+3 −1
Original line number Diff line number Diff line
@@ -9879,6 +9879,8 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener

        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            hide();

            if (view instanceof TextView) {
                TextView textView = (TextView) view;
                Editable editable = (Editable) mText;
@@ -9886,6 +9888,7 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
                SuggestionInfo suggestionInfo = mSuggestionInfos[position];
                final int spanStart = editable.getSpanStart(suggestionInfo.suggestionSpan);
                final int spanEnd = editable.getSpanEnd(suggestionInfo.suggestionSpan);
                if (spanStart < 0 || spanEnd < 0) return; // Span has been removed
                final String originalText = mText.subSequence(spanStart, spanEnd).toString();

                if (suggestionInfo.suggestionIndex < 0) {
@@ -9947,7 +9950,6 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
                    Selection.setSelection(editable, spanEnd + lengthDifference);
                }
            }
            hide();
        }
    }