diff options
author | 2014-09-08 13:30:05 +0000 | |
---|---|---|
committer | 2014-09-08 13:30:05 +0000 | |
commit | aad99530b0984a2b66143d4c8826fe4c0f281cfc (patch) | |
tree | 6e8313a1f32dfafcd11e5bd4915afd70d215a65e /java/src/com/android/inputmethod/latin/RichInputConnection.java | |
parent | 93770226da71294ce828dabcff2ed516433ac0de (diff) | |
parent | 1cf2acd8de53e1b6fa156af065330c687ccdcb86 (diff) | |
download | latinime-aad99530b0984a2b66143d4c8826fe4c0f281cfc.tar.gz latinime-aad99530b0984a2b66143d4c8826fe4c0f281cfc.tar.xz latinime-aad99530b0984a2b66143d4c8826fe4c0f281cfc.zip |
am 1cf2acd8: am 61e7afa6: am 0eaa25e0: am 914078fd: Fix a bug where recorrection would stop on connectors
* commit '1cf2acd8de53e1b6fa156af065330c687ccdcb86':
Fix a bug where recorrection would stop on connectors
Diffstat (limited to 'java/src/com/android/inputmethod/latin/RichInputConnection.java')
-rw-r--r-- | java/src/com/android/inputmethod/latin/RichInputConnection.java | 20 |
1 files changed, 14 insertions, 6 deletions
diff --git a/java/src/com/android/inputmethod/latin/RichInputConnection.java b/java/src/com/android/inputmethod/latin/RichInputConnection.java index 0e85d13b6..dc00ecc8f 100644 --- a/java/src/com/android/inputmethod/latin/RichInputConnection.java +++ b/java/src/com/android/inputmethod/latin/RichInputConnection.java @@ -623,14 +623,24 @@ public final class RichInputConnection { return Arrays.binarySearch(sortedSeparators, code) >= 0; } + private static boolean isPartOfCompositionForScript(final int codePoint, + final SpacingAndPunctuations spacingAndPunctuations, final int scriptId) { + // We always consider word connectors part of compositions. + return spacingAndPunctuations.isWordConnector(codePoint) + // Otherwise, it's part of composition if it's part of script and not a separator. + || (!spacingAndPunctuations.isWordSeparator(codePoint) + && ScriptUtils.isLetterPartOfScript(codePoint, scriptId)); + } + /** * Returns the text surrounding the cursor. * - * @param sortedSeparators a sorted array of code points that split words. + * @param spacingAndPunctuations the rules for spacing and punctuation * @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, final int scriptId) { + public TextRange getWordRangeAtCursor(final SpacingAndPunctuations spacingAndPunctuations, + final int scriptId) { mIC = mParent.getCurrentInputConnection(); if (mIC == null) { return null; @@ -647,8 +657,7 @@ public final class RichInputConnection { int startIndexInBefore = before.length(); while (startIndexInBefore > 0) { final int codePoint = Character.codePointBefore(before, startIndexInBefore); - if (isSeparator(codePoint, sortedSeparators) - || !ScriptUtils.isLetterPartOfScript(codePoint, scriptId)) { + if (!isPartOfCompositionForScript(codePoint, spacingAndPunctuations, scriptId)) { break; } --startIndexInBefore; @@ -661,8 +670,7 @@ public final class RichInputConnection { int endIndexInAfter = -1; while (++endIndexInAfter < after.length()) { final int codePoint = Character.codePointAt(after, endIndexInAfter); - if (isSeparator(codePoint, sortedSeparators) - || !ScriptUtils.isLetterPartOfScript(codePoint, scriptId)) { + if (!isPartOfCompositionForScript(codePoint, spacingAndPunctuations, scriptId)) { break; } if (Character.isSupplementaryCodePoint(codePoint)) { |