Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 4895ec3d authored by Jean Chalard's avatar Jean Chalard Committed by Android Git Automerger
Browse files

am 940a2ad6: Merge "Don\'t send the same values to onUpdateSelection repeatedly" into klp-dev

* commit '940a2ad6':
  Don't send the same values to onUpdateSelection repeatedly
parents 736469ad 940a2ad6
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
@@ -1651,6 +1651,11 @@ public class InputMethodService extends AbstractInputMethodService {
     * extracted text updates, although if so it will not receive this call
     * if the extracted text has changed as well.
     *
     * <p>Be careful about changing the text in reaction to this call with
     * methods such as setComposingText, commitText or
     * deleteSurroundingText. If the cursor moves as a result, this method
     * will be called again, which may result in an infinite loop.
     * 
     * <p>The default implementation takes care of updating the cursor in
     * the extract text, if it is being shown.
     */
+7 −2
Original line number Diff line number Diff line
@@ -1412,12 +1412,17 @@ public final class InputMethodManager {

                try {
                    if (DEBUG) Log.v(TAG, "SELECTION CHANGE: " + mCurMethod);
                    mCurMethod.updateSelection(mCursorSelStart, mCursorSelEnd,
                            selStart, selEnd, candidatesStart, candidatesEnd);
                    final int oldSelStart = mCursorSelStart;
                    final int oldSelEnd = mCursorSelEnd;
                    // Update internal values before sending updateSelection to the IME, because
                    // if it changes the text within its onUpdateSelection handler in a way that
                    // does not move the cursor we don't want to call it again with the same values.
                    mCursorSelStart = selStart;
                    mCursorSelEnd = selEnd;
                    mCursorCandStart = candidatesStart;
                    mCursorCandEnd = candidatesEnd;
                    mCurMethod.updateSelection(oldSelStart, oldSelEnd,
                            selStart, selEnd, candidatesStart, candidatesEnd);
                } catch (RemoteException e) {
                    Log.w(TAG, "IME died: " + mCurId, e);
                }