Instead of ignoring PARAGRAPH spans, fix them.

I don't know what or when this flag is set, but it's only bad
news. Luckily, we can just remove it.

Bug: 12119393
Change-Id: I2952138c8ce517535b91e0fe25d2cf4960e02862
main
Jean Chalard 2013-12-13 22:13:25 +09:00
parent 7a904514fb
commit 330d2720bb
1 changed files with 7 additions and 2 deletions

View File

@ -45,7 +45,12 @@ public final class SpannableStringUtils {
for (int i = 0; i < spans.length; i++) { for (int i = 0; i < spans.length; i++) {
int fl = source.getSpanFlags(spans[i]); int fl = source.getSpanFlags(spans[i]);
if (0 != (fl & Spannable.SPAN_PARAGRAPH)) continue; // We don't care about the PARAGRAPH flag in LatinIME code. However, if this flag
// is set, Spannable#setSpan will throw an exception unless the span is on the edge
// of a word. But the spans have been split into two by the getText{Before,After}Cursor
// methods, so after concatenation they may end in the middle of a word.
// Since we don't use them, we can just remove them and avoid crashing.
fl &= ~Spannable.SPAN_PARAGRAPH;
int st = source.getSpanStart(spans[i]); int st = source.getSpanStart(spans[i]);
int en = source.getSpanEnd(spans[i]); int en = source.getSpanEnd(spans[i]);