aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJean Chalard <jchalard@google.com>2013-12-13 08:34:17 -0800
committerAndroid Git Automerger <android-git-automerger@android.com>2013-12-13 08:34:17 -0800
commita231b3baa2f83d32adf15fd474bcb7b4fd702514 (patch)
tree3936bc412b09dd982a9cf1f315e279b205f9abc8
parent30db835b290cb88ea361fcc96ec53f799a95a6b2 (diff)
parent330d2720bb3b0b6333ec2f61f056a4f46cbfa106 (diff)
downloadlatinime-a231b3baa2f83d32adf15fd474bcb7b4fd702514.tar.gz
latinime-a231b3baa2f83d32adf15fd474bcb7b4fd702514.tar.xz
latinime-a231b3baa2f83d32adf15fd474bcb7b4fd702514.zip
am 330d2720: Instead of ignoring PARAGRAPH spans, fix them.
* commit '330d2720bb3b0b6333ec2f61f056a4f46cbfa106': Instead of ignoring PARAGRAPH spans, fix them.
-rw-r--r--java/src/com/android/inputmethod/latin/utils/SpannableStringUtils.java9
1 files changed, 7 insertions, 2 deletions
diff --git a/java/src/com/android/inputmethod/latin/utils/SpannableStringUtils.java b/java/src/com/android/inputmethod/latin/utils/SpannableStringUtils.java
index b51fd9377..be0955456 100644
--- a/java/src/com/android/inputmethod/latin/utils/SpannableStringUtils.java
+++ b/java/src/com/android/inputmethod/latin/utils/SpannableStringUtils.java
@@ -40,12 +40,17 @@ public final class SpannableStringUtils {
* are out of range in <code>dest</code>.
*/
public static void copyNonParagraphSuggestionSpansFrom(Spanned source, int start, int end,
- Spannable dest, int destoff) {
+ Spannable dest, int destoff) {
Object[] spans = source.getSpans(start, end, SuggestionSpan.class);
for (int i = 0; i < spans.length; 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 en = source.getSpanEnd(spans[i]);