Make the autoscroll feature also work for a very short document

This commit is contained in:
Veronica K. B. Olsen
2021-01-23 15:12:25 +01:00
parent 2e1d5d4d13
commit 1ddadeba5d
+3 -2
View File
@@ -454,8 +454,9 @@ class GuiDocEditor(QTextEdit):
docChanged = self.docChanged
if self.mainConf.scrollPastEnd:
scrlFac = max(1 - self.mainConf.autoScrollPos*0.01, 0.6)
docFrame = self.qDocument.rootFrame().frameFormat()
docFrame.setBottomMargin(max(0, 0.6*(wH - uM - lM - 4*tB)))
docFrame.setBottomMargin(max(0, scrlFac*(wH - uM - lM - 4*tB)))
self.qDocument.rootFrame().setFrameFormat(docFrame)
# This is needed as the setFrameFormat function itself will
@@ -847,7 +848,7 @@ class GuiDocEditor(QTextEdit):
if okMod and okKey:
cNew = self.cursorRect().center().y()
cMov = cNew - cOld
mPos = self.mainConf.autoScrollPos * self.viewport().height() * 0.01
mPos = self.mainConf.autoScrollPos*0.01 * self.viewport().height()
if abs(cMov) > 0 and cOld > mPos:
# Move the scroll bar
vBar = self.verticalScrollBar()