aboutsummaryrefslogtreecommitdiffstats
path: root/java/src
diff options
context:
space:
mode:
authorKen Wakasa <kwakasa@google.com>2014-07-01 03:22:15 +0000
committerKen Wakasa <kwakasa@google.com>2014-07-01 03:22:15 +0000
commitf84573c0b3128609e6d73ea61f2aa1a1dac762a4 (patch)
treee59cc8c4482523b4bd427a9b908cefef563d4170 /java/src
parent2a5824a63b244d1e5b18e512bc8dfb34f795f579 (diff)
downloadlatinime-f84573c0b3128609e6d73ea61f2aa1a1dac762a4.tar.gz
latinime-f84573c0b3128609e6d73ea61f2aa1a1dac762a4.tar.xz
latinime-f84573c0b3128609e6d73ea61f2aa1a1dac762a4.zip
Revert "[SD6] Inline a constant and remove logic become useless"
This reverts commit 2a5824a63b244d1e5b18e512bc8dfb34f795f579 that broke the build. Bug: 15840116 Change-Id: Ife11050394f3ed90e39d835b92732e1b6af83249
Diffstat (limited to 'java/src')
-rw-r--r--java/src/com/android/inputmethod/latin/RichInputConnection.java29
1 files changed, 21 insertions, 8 deletions
diff --git a/java/src/com/android/inputmethod/latin/RichInputConnection.java b/java/src/com/android/inputmethod/latin/RichInputConnection.java
index 5e0dafa57..96bf17b5c 100644
--- a/java/src/com/android/inputmethod/latin/RichInputConnection.java
+++ b/java/src/com/android/inputmethod/latin/RichInputConnection.java
@@ -626,6 +626,7 @@ public final class RichInputConnection {
* @return a range containing the text surrounding the cursor
*/
public TextRange getWordRangeAtCursor(final int[] sortedSeparators) {
+ final int additionalPrecedingWordsCount = 0;
mIC = mParent.getCurrentInputConnection();
if (mIC == null) {
return null;
@@ -638,17 +639,29 @@ public final class RichInputConnection {
return null;
}
- // Going backward, find the first breaking point (separator)
+ // Going backward, alternate skipping non-separators and separators until enough words
+ // have been read.
+ int count = additionalPrecedingWordsCount;
int startIndexInBefore = before.length();
- while (startIndexInBefore > 0) {
- final int codePoint = Character.codePointBefore(before, startIndexInBefore);
- if (isSeparator(codePoint, sortedSeparators)) {
- break;
- }
- --startIndexInBefore;
- if (Character.isSupplementaryCodePoint(codePoint)) {
+ boolean isStoppingAtWhitespace = true; // toggles to indicate what to stop at
+ while (true) { // see comments below for why this is guaranteed to halt
+ while (startIndexInBefore > 0) {
+ final int codePoint = Character.codePointBefore(before, startIndexInBefore);
+ if (isStoppingAtWhitespace == isSeparator(codePoint, sortedSeparators)) {
+ break; // inner loop
+ }
--startIndexInBefore;
+ if (Character.isSupplementaryCodePoint(codePoint)) {
+ --startIndexInBefore;
+ }
+ }
+ // isStoppingAtWhitespace is true every other time through the loop,
+ // so additionalPrecedingWordsCount is guaranteed to become < 0, which
+ // guarantees outer loop termination
+ if (isStoppingAtWhitespace && (--count < 0)) {
+ break; // outer loop
}
+ isStoppingAtWhitespace = !isStoppingAtWhitespace;
}
// Find last word separator after the cursor