Make go to line in editor work consistently with auto-scrolling
This commit is contained in:
@@ -666,12 +666,17 @@ class GuiDocEditor(QTextEdit):
|
|||||||
theCursor.setPosition(minmax(position, 0, nChars-1))
|
theCursor.setPosition(minmax(position, 0, nChars-1))
|
||||||
self.setTextCursor(theCursor)
|
self.setTextCursor(theCursor)
|
||||||
|
|
||||||
# The editor scrolls so the cursor is on the last line, so we must correct
|
# By default, the editor scrolls so the cursor is on the
|
||||||
vPos = self.verticalScrollBar().value() # Current scrollbar position
|
# last line, so we must correct it. The user setting for
|
||||||
cPos = self.cursorRect().topLeft().y() # Cursor position to scroll to
|
# auto-scroll is used to determine the scroll distance. This
|
||||||
dMrg = int(self.document().documentMargin()) # Document margin to subtract
|
# makes it compatible with the typewriter scrolling feature
|
||||||
mPos = int(self.viewport().height()*0.1) # Distance from top to adjust for (10%)
|
# when it is enabled. By default, it's 30% of viewport.
|
||||||
self.verticalScrollBar().setValue(max(0, vPos + cPos - dMrg - mPos))
|
vPos = self.verticalScrollBar().value()
|
||||||
|
cPos = self.cursorRect().topLeft().y()
|
||||||
|
mPos = int(self.mainConf.autoScrollPos*0.01 * self.viewport().height())
|
||||||
|
if cPos > mPos:
|
||||||
|
# Only scroll if the cursor is past the auto-scroll limit
|
||||||
|
self.verticalScrollBar().setValue(max(0, vPos + cPos - mPos))
|
||||||
|
|
||||||
self.docFooter.updateLineCount()
|
self.docFooter.updateLineCount()
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user