From 292deb632cbab232334190e68d29184094d6d51b Mon Sep 17 00:00:00 2001 From: Jean Chalard Date: Fri, 27 Jun 2014 22:44:24 +0900 Subject: [SD7] Actually check for script. ...also implement the check for Hebrew and Arabic. Bug: 15840116 Change-Id: Ia6433d7d98038ade64c171be4fe4b3f094111fac --- .../src/com/android/inputmethod/latin/RichInputConnection.java | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'java/src/com/android/inputmethod/latin/RichInputConnection.java') diff --git a/java/src/com/android/inputmethod/latin/RichInputConnection.java b/java/src/com/android/inputmethod/latin/RichInputConnection.java index 5e0dafa57..fdd47a40f 100644 --- a/java/src/com/android/inputmethod/latin/RichInputConnection.java +++ b/java/src/com/android/inputmethod/latin/RichInputConnection.java @@ -30,6 +30,7 @@ import com.android.inputmethod.latin.PrevWordsInfo.WordInfo; import com.android.inputmethod.latin.settings.SpacingAndPunctuations; import com.android.inputmethod.latin.utils.CapsModeUtils; import com.android.inputmethod.latin.utils.DebugLogUtils; +import com.android.inputmethod.latin.utils.ScriptUtils; import com.android.inputmethod.latin.utils.SpannableStringUtils; import com.android.inputmethod.latin.utils.StringUtils; import com.android.inputmethod.latin.utils.TextRange; @@ -623,9 +624,10 @@ public final class RichInputConnection { * Returns the text surrounding the cursor. * * @param sortedSeparators a sorted array of code points that split words. + * @param scriptId the script we consider to be writing words, as one of ScriptUtils.SCRIPT_* * @return a range containing the text surrounding the cursor */ - public TextRange getWordRangeAtCursor(final int[] sortedSeparators) { + public TextRange getWordRangeAtCursor(final int[] sortedSeparators, final int scriptId) { mIC = mParent.getCurrentInputConnection(); if (mIC == null) { return null; @@ -642,7 +644,8 @@ public final class RichInputConnection { int startIndexInBefore = before.length(); while (startIndexInBefore > 0) { final int codePoint = Character.codePointBefore(before, startIndexInBefore); - if (isSeparator(codePoint, sortedSeparators)) { + if (isSeparator(codePoint, sortedSeparators) + || !ScriptUtils.isLetterPartOfScript(codePoint, scriptId)) { break; } --startIndexInBefore; @@ -655,7 +658,8 @@ public final class RichInputConnection { int endIndexInAfter = -1; while (++endIndexInAfter < after.length()) { final int codePoint = Character.codePointAt(after, endIndexInAfter); - if (isSeparator(codePoint, sortedSeparators)) { + if (isSeparator(codePoint, sortedSeparators) + || !ScriptUtils.isLetterPartOfScript(codePoint, scriptId)) { break; } if (Character.isSupplementaryCodePoint(codePoint)) { -- cgit v1.2.3-83-g751a