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

Commit a465a170 authored by Dianne Hackborn's avatar Dianne Hackborn
Browse files

Fix bugs 1827027, 1808979, 1820700.

These are all variations of needing to validate ranges on editing operations
coming from the IME, to account for the underlying text changing (usually being
deleted) asynchronously with the IME.
parent ecfb9f91
Loading
Loading
Loading
Loading
+10 −6
Original line number Diff line number Diff line
@@ -297,6 +297,10 @@ public class BaseInputConnection implements InputConnection {
            b = tmp;
        }

        if (a <= 0) {
            return "";
        }
        
        if (length > a) {
            length = a;
        }
@@ -488,14 +492,14 @@ public class BaseInputConnection implements InputConnection {
        } else {
            a = Selection.getSelectionStart(content);
            b = Selection.getSelectionEnd(content);
            if (a >=0 && b>= 0 && a != b) {
            if (a < 0) a = 0;
            if (b < 0) b = 0;
            if (b < a) {
                int tmp = a;
                a = b;
                b = tmp;
            }
        }
        }

        if (composing) {
            Spannable sp = null;
+7 −0
Original line number Diff line number Diff line
@@ -6469,6 +6469,13 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
        
        protected void onReceiveResult(int resultCode, Bundle resultData) {
            if (resultCode != InputMethodManager.RESULT_SHOWN) {
                final int len = mText.length();
                if (mNewStart > len) {
                    mNewStart = len;
                }
                if (mNewEnd > len) {
                    mNewEnd = len;
                }
                Selection.setSelection((Spannable)mText, mNewStart, mNewEnd);
            }
        }