summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGilles Debunne <debunne@google.com>2011-10-21 09:48:07 -0700
committerAndroid (Google) Code Review <android-gerrit@google.com>2011-10-21 09:48:07 -0700
commit0499f90a2d2774f28ca3d430dfe563391669c515 (patch)
tree13beea45a075cacf9998ea970a720012e07a43af
parent4e7ce9352b9c3a832715ac4b8014b2434a447172 (diff)
parent592ddaa34f5a6799e4bb707996a3b8308448282e (diff)
downloadframeworks_base-0499f90a2d2774f28ca3d430dfe563391669c515.zip
frameworks_base-0499f90a2d2774f28ca3d430dfe563391669c515.tar.gz
frameworks_base-0499f90a2d2774f28ca3d430dfe563391669c515.tar.bz2
Merge "Bug 5428541: Check that span is still in text before deleting" into ics-mr0
-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;
}