summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGilles Debunne <debunne@google.com>2011-10-11 16:01:22 -0700
committerGilles Debunne <debunne@google.com>2011-10-20 16:03:04 -0700
commit592ddaa34f5a6799e4bb707996a3b8308448282e (patch)
tree996dc90865ed95e06809c4425bb973f24f65929f
parent2159927f366fd8a617128df60865923e131cad7b (diff)
downloadframeworks_base-592ddaa34f5a6799e4bb707996a3b8308448282e.zip
frameworks_base-592ddaa34f5a6799e4bb707996a3b8308448282e.tar.gz
frameworks_base-592ddaa34f5a6799e4bb707996a3b8308448282e.tar.bz2
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
-rw-r--r--core/java/android/widget/TextView.java14
1 files changed, 8 insertions, 6 deletions
diff --git a/core/java/android/widget/TextView.java b/core/java/android/widget/TextView.java
index a21a087..7f03adf 100644
--- a/core/java/android/widget/TextView.java
+++ b/core/java/android/widget/TextView.java
@@ -9891,14 +9891,16 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
if (suggestionInfo.suggestionIndex == DELETE_TEXT) {
final int spanUnionStart = editable.getSpanStart(mSuggestionRangeSpan);
int spanUnionEnd = editable.getSpanEnd(mSuggestionRangeSpan);
- // Do not leave two adjacent spaces after deletion, or one at beginning of text
- if (spanUnionEnd < editable.length() &&
- Character.isSpaceChar(editable.charAt(spanUnionEnd)) &&
- (spanUnionStart == 0 ||
- Character.isSpaceChar(editable.charAt(spanUnionStart - 1)))) {
+ 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)) &&
+ (spanUnionStart == 0 ||
+ Character.isSpaceChar(editable.charAt(spanUnionStart - 1)))) {
spanUnionEnd = spanUnionEnd + 1;
+ }
+ editable.replace(spanUnionStart, spanUnionEnd, "");
}
- editable.replace(spanUnionStart, spanUnionEnd, "");
hide();
return;
}