diff options
author | 2013-09-12 19:11:59 +0900 | |
---|---|---|
committer | 2013-09-24 19:04:51 +0900 | |
commit | 3d68b066626d7e58cbe2853cd186b1ad75b90259 (patch) | |
tree | 532d7a016d69e3b54773f5cb4a89fc7ec0796ad7 /java/src/com/android/inputmethod/latin/RichInputConnection.java | |
parent | 3ca9c5cbec9ee8eb61b37bb5d11b7e0bc3dc41cc (diff) | |
download | latinime-3d68b066626d7e58cbe2853cd186b1ad75b90259.tar.gz latinime-3d68b066626d7e58cbe2853cd186b1ad75b90259.tar.xz latinime-3d68b066626d7e58cbe2853cd186b1ad75b90259.zip |
Copy only the spans we are interested in.
The PARAGRAPH type of span is dangerous, as concatenating
CharSequences that contain it may crash. We also don't use
other spans than SuggestionSpans, so we don't copy them.
Bug: 10622489
Change-Id: If4e44eca3cdc5bb02cf2e0c8c44ecd4bf27fae57
Diffstat (limited to 'java/src/com/android/inputmethod/latin/RichInputConnection.java')
-rw-r--r-- | java/src/com/android/inputmethod/latin/RichInputConnection.java | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/java/src/com/android/inputmethod/latin/RichInputConnection.java b/java/src/com/android/inputmethod/latin/RichInputConnection.java index fa7f23efb..925381b50 100644 --- a/java/src/com/android/inputmethod/latin/RichInputConnection.java +++ b/java/src/com/android/inputmethod/latin/RichInputConnection.java @@ -607,8 +607,11 @@ public final class RichInputConnection { } } - return new TextRange(TextUtils.concat(before, after), startIndexInBefore, - before.length() + endIndexInAfter, before.length()); + // We don't use TextUtils#concat because it copies all spans without respect to their + // nature. If the text includes a PARAGRAPH span and it has been split, then + // TextUtils#concat will crash when it tries to concat both sides of it. + return new TextRange(StringUtils.concatWithNonParagraphSuggestionSpansOnly(before, after), + startIndexInBefore, before.length() + endIndexInAfter, before.length()); } public boolean isCursorTouchingWord(final SettingsValues settingsValues) { |