aboutsummaryrefslogtreecommitdiffstats
path: root/java/src
diff options
context:
space:
mode:
Diffstat (limited to 'java/src')
-rw-r--r--java/src/com/android/inputmethod/latin/RichInputConnection.java24
1 files changed, 17 insertions, 7 deletions
diff --git a/java/src/com/android/inputmethod/latin/RichInputConnection.java b/java/src/com/android/inputmethod/latin/RichInputConnection.java
index 965518e34..606bb775e 100644
--- a/java/src/com/android/inputmethod/latin/RichInputConnection.java
+++ b/java/src/com/android/inputmethod/latin/RichInputConnection.java
@@ -687,13 +687,23 @@ public final class RichInputConnection {
}
public boolean isCursorTouchingWord(final SpacingAndPunctuations spacingAndPunctuations) {
- final int codePointBeforeCursor = getCodePointBeforeCursor();
- if (Constants.NOT_A_CODE == codePointBeforeCursor
- || spacingAndPunctuations.isWordSeparator(codePointBeforeCursor)
- || spacingAndPunctuations.isWordConnector(codePointBeforeCursor)) {
- return isCursorFollowedByWordCharacter(spacingAndPunctuations);
- }
- return true;
+ if (isCursorFollowedByWordCharacter(spacingAndPunctuations)) {
+ // If what's after the cursor is a word character, then we're touching a word.
+ return true;
+ }
+ final String textBeforeCursor = mCommittedTextBeforeComposingText.toString();
+ int indexOfCodePointInJavaChars = textBeforeCursor.length();
+ int consideredCodePoint = 0 == indexOfCodePointInJavaChars ? Constants.NOT_A_CODE
+ : textBeforeCursor.codePointBefore(indexOfCodePointInJavaChars);
+ // Search for the first non word-connector char
+ if (spacingAndPunctuations.isWordConnector(consideredCodePoint)) {
+ indexOfCodePointInJavaChars -= Character.charCount(consideredCodePoint);
+ consideredCodePoint = 0 == indexOfCodePointInJavaChars ? Constants.NOT_A_CODE
+ : textBeforeCursor.codePointBefore(indexOfCodePointInJavaChars);
+ }
+ return !(Constants.NOT_A_CODE == consideredCodePoint
+ || spacingAndPunctuations.isWordSeparator(consideredCodePoint)
+ || spacingAndPunctuations.isWordConnector(consideredCodePoint));
}
public boolean isCursorFollowedByWordCharacter(