@@ -5504,8 +5504,8 @@ private void scrollEditIntoView() {
55045504 if (visibleRect .contains (mEditTextContentBounds )) {
55055505 return ; // no need to scroll
55065506 }
5507- nativeFindMaxVisibleRect (mNativeClass , mEditTextLayerId , visibleRect );
55085507 syncSelectionCursors ();
5508+ nativeFindMaxVisibleRect (mNativeClass , mEditTextLayerId , visibleRect );
55095509 final int buffer = Math .max (1 , viewToContentDimension (EDIT_RECT_BUFFER ));
55105510 Rect showRect = new Rect (
55115511 Math .max (0 , mEditTextContentBounds .left - buffer ),
@@ -5538,17 +5538,19 @@ private void scrollEditIntoView() {
55385538 return ; // no need to scroll
55395539 }
55405540
5541- int scrollX = visibleRect . left ;
5541+ int scrollX = viewToContentX ( getScrollX ()) ;
55425542 if (visibleRect .left > showRect .left ) {
5543- scrollX = showRect .left ;
5543+ // We are scrolled too far
5544+ scrollX += showRect .left - visibleRect .left ;
55445545 } else if (visibleRect .right < showRect .right ) {
5545- scrollX = Math .max (0 , showRect .right - visibleRect .width ());
5546+ // We aren't scrolled enough to include the right
5547+ scrollX += showRect .right - visibleRect .right ;
55465548 }
5547- int scrollY = visibleRect . top ;
5549+ int scrollY = viewToContentY ( getScrollY ()) ;
55485550 if (visibleRect .top > showRect .top ) {
5549- scrollY = showRect .top ;
5551+ scrollY + = showRect . top - visibleRect .top ;
55505552 } else if (visibleRect .bottom < showRect .bottom ) {
5551- scrollY = Math . max ( 0 , showRect .bottom - visibleRect .height ()) ;
5553+ scrollY += showRect .bottom - visibleRect .bottom ;
55525554 }
55535555
55545556 contentScrollTo (scrollX , scrollY , false );
0 commit comments