@@ -666,12 +666,17 @@ def setCursorPosition(self, position):
666666 theCursor .setPosition (minmax (position , 0 , nChars - 1 ))
667667 self .setTextCursor (theCursor )
668668
669- # The editor scrolls so the cursor is on the last line, so we must correct
670- vPos = self .verticalScrollBar ().value () # Current scrollbar position
671- cPos = self .cursorRect ().topLeft ().y () # Cursor position to scroll to
672- dMrg = int (self .document ().documentMargin ()) # Document margin to subtract
673- mPos = int (self .viewport ().height ()* 0.1 ) # Distance from top to adjust for (10%)
674- self .verticalScrollBar ().setValue (max (0 , vPos + cPos - dMrg - mPos ))
669+ # By default, the editor scrolls so the cursor is on the
670+ # last line, so we must correct it. The user setting for
671+ # auto-scroll is used to determine the scroll distance. This
672+ # makes it compatible with the typewriter scrolling feature
673+ # when it is enabled. By default, it's 30% of viewport.
674+ vPos = self .verticalScrollBar ().value ()
675+ cPos = self .cursorRect ().topLeft ().y ()
676+ mPos = int (self .mainConf .autoScrollPos * 0.01 * self .viewport ().height ())
677+ if cPos > mPos :
678+ # Only scroll if the cursor is past the auto-scroll limit
679+ self .verticalScrollBar ().setValue (max (0 , vPos + cPos - mPos ))
675680
676681 self .docFooter .updateLineCount ()
677682
0 commit comments