aboutsummaryrefslogtreecommitdiffstats
path: root/java/src
diff options
context:
space:
mode:
Diffstat (limited to 'java/src')
-rw-r--r--java/src/com/android/inputmethod/latin/LatinIME.java15
-rw-r--r--java/src/com/android/inputmethod/latin/RichInputConnection.java9
2 files changed, 14 insertions, 10 deletions
diff --git a/java/src/com/android/inputmethod/latin/LatinIME.java b/java/src/com/android/inputmethod/latin/LatinIME.java
index 73ec57871..67b2e0fdb 100644
--- a/java/src/com/android/inputmethod/latin/LatinIME.java
+++ b/java/src/com/android/inputmethod/latin/LatinIME.java
@@ -884,19 +884,15 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
}
}
- // TODO: refactor the following code to be less contrived.
- // "newSelStart != composingSpanEnd" || "newSelEnd != composingSpanEnd" means
- // that the cursor is not at the end of the composing span, or there is a selection.
- // "mLastSelectionStart != newSelStart" means that the cursor is not in the same place
- // as last time we were called (if there is a selection, it means the start hasn't
- // changed, so it's the end that did).
- final boolean selectionChanged = (newSelStart != composingSpanEnd
- || newSelEnd != composingSpanEnd) && mLastSelectionStart != newSelStart;
+ final boolean selectionChanged = mLastSelectionStart != newSelStart
+ || mLastSelectionEnd != newSelEnd;
// if composingSpanStart and composingSpanEnd are -1, it means there is no composing
// span in the view - we can use that to narrow down whether the cursor was moved
// by us or not. If we are composing a word but there is no composing span, then
// we know for sure the cursor moved while we were composing and we should reset
- // the state.
+ // the state. TODO: rescind this policy: the framework never removes the composing
+ // span on its own accord while editing. This test is useless.
+
final boolean noComposingSpan = composingSpanStart == -1 && composingSpanEnd == -1;
// If the keyboard is not visible, we don't need to do all the housekeeping work, as it
// will be reset when the keyboard shows up anyway.
@@ -937,6 +933,7 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
if (isSuggestionsStripVisible()) {
mHandler.postResumeSuggestions();
}
+ mConnection.userMovedCursor(newSelEnd);
// Reset the last recapitalization.
mRecapitalizeStatus.deactivate();
mKeyboardSwitcher.updateShiftState();
diff --git a/java/src/com/android/inputmethod/latin/RichInputConnection.java b/java/src/com/android/inputmethod/latin/RichInputConnection.java
index 980215de6..6226f9b21 100644
--- a/java/src/com/android/inputmethod/latin/RichInputConnection.java
+++ b/java/src/com/android/inputmethod/latin/RichInputConnection.java
@@ -338,7 +338,6 @@ public final class RichInputConnection {
public void setComposingRegion(final int start, final int end) {
if (DEBUG_BATCH_NESTING) checkBatchEdit();
if (DEBUG_PREVIOUS_TEXT) checkConsistencyForDebug();
- mCurrentCursorPosition = end;
final CharSequence textBeforeCursor =
getTextBeforeCursor(DEFAULT_TEXT_CACHE_SIZE + (end - start), 0);
mCommittedTextBeforeComposingText.setLength(0);
@@ -723,6 +722,14 @@ public final class RichInputConnection {
}
/**
+ * The user moved the cursor by hand. Take a note of it.
+ * @param newCursorPosition The new cursor position.
+ */
+ public void userMovedCursor(final int newCursorPosition) {
+ mCurrentCursorPosition = newCursorPosition;
+ }
+
+ /**
* Looks at the text just before the cursor to find out if it looks like a URL.
*
* The weakest point here is, if we don't have enough text bufferized, we may fail to realize