diff --git a/core/java/android/view/inputmethod/BaseInputConnection.java b/core/java/android/view/inputmethod/BaseInputConnection.java index 7ec53980876be..b3ff54d0b5c83 100644 --- a/core/java/android/view/inputmethod/BaseInputConnection.java +++ b/core/java/android/view/inputmethod/BaseInputConnection.java @@ -268,8 +268,9 @@ public class BaseInputConnection implements InputConnection { if (content != null) { beginBatchEdit(); removeComposingSpans(content); - endBatchEdit(); + // Note: sendCurrentText does nothing unless mDummyMode is set sendCurrentText(); + endBatchEdit(); } return true; } @@ -466,8 +467,9 @@ public class BaseInputConnection implements InputConnection { content.setSpan(COMPOSING, a, b, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE | Spanned.SPAN_COMPOSING); - endBatchEdit(); + // Note: sendCurrentText does nothing unless mDummyMode is set sendCurrentText(); + endBatchEdit(); } return true; } diff --git a/core/java/android/widget/Editor.java b/core/java/android/widget/Editor.java index 8f90fa5496de6..5848f1f396821 100644 --- a/core/java/android/widget/Editor.java +++ b/core/java/android/widget/Editor.java @@ -1085,9 +1085,12 @@ public class Editor { mTextView.updateAfterEdit(); reportExtractedText(); } else if (ims.mCursorChanged) { - // Cheezy way to get us to report the current cursor location. + // Cheesy way to get us to report the current cursor location. mTextView.invalidateCursor(); } + // sendUpdateSelection knows to avoid sending if the selection did + // not actually change. + sendUpdateSelection(); } static final int EXTRACT_NOTHING = -2; @@ -1221,6 +1224,8 @@ public class Editor { candStart = EditableInputConnection.getComposingSpanStart(sp); candEnd = EditableInputConnection.getComposingSpanEnd(sp); } + // InputMethodManager#updateSelection skips sending the message if + // none of the parameters have changed since the last time we called it. imm.updateSelection(mTextView, selectionStart, selectionEnd, candStart, candEnd); } @@ -1244,11 +1249,6 @@ public class Editor { // input method. reported = reportExtractedText(); } - if (!reported && highlight != null) { - // TODO: stop doing this here, and do it after each change - // as needed instead. - sendUpdateSelection(); - } } if (imm.isWatchingCursor(mTextView) && highlight != null) {