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

Commit 28ef9040 authored by Gilles Debunne's avatar Gilles Debunne
Browse files

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

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

Change-Id: I6478e0953cab132a984174b596d1f813909cdc2d
parent 1eb08f0a
Loading
Loading
Loading
Loading
+8 −6
Original line number Diff line number Diff line
@@ -9889,6 +9889,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)) &&
@@ -9897,6 +9898,7 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
                        spanUnionEnd = spanUnionEnd + 1;
                    }
                    editable.replace(spanUnionStart, spanUnionEnd, "");
                }
                hide();
                return;
            }