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

Commit 592ddaa3 authored by Gilles Debunne's avatar Gilles Debunne
Browse files

Bug 5428541: Check that span is still in text before deleting

This is a cherry-pick in MR0 of CL 141388 from master.

Bug 5488537

In case the span has been removed from the text since the popup
was showed, the delete action is a no-op.

Change-Id: Iec2aeaf03becd82ad44715d5c08bfaa8f62aa3fe
parent 2159927f
Loading
Loading
Loading
Loading
+8 −6
Original line number Diff line number Diff line
@@ -9891,6 +9891,7 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
            if (suggestionInfo.suggestionIndex == DELETE_TEXT) {
                final int spanUnionStart = editable.getSpanStart(mSuggestionRangeSpan);
                int spanUnionEnd = editable.getSpanEnd(mSuggestionRangeSpan);
                if (spanUnionStart >= 0 && spanUnionEnd > spanUnionStart) {
                    // Do not leave two adjacent spaces after deletion, or one at beginning of text
                    if (spanUnionEnd < editable.length() &&
                            Character.isSpaceChar(editable.charAt(spanUnionEnd)) &&
@@ -9899,6 +9900,7 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
                        spanUnionEnd = spanUnionEnd + 1;
                    }
                    editable.replace(spanUnionStart, spanUnionEnd, "");
                }
                hide();
                return;
            }