fix: scroll to last line

This commit is contained in:
Roy Qu 2024-03-23 17:49:13 +08:00
parent 79274d786a
commit 67f9cbe6ee
1 changed files with 4 additions and 4 deletions

View File

@ -3110,7 +3110,7 @@ void QSynEdit::updateHScrollbar()
} }
if (mScrollBars == ScrollStyle::ssBoth || mScrollBars == ScrollStyle::ssHorizontal) { if (mScrollBars == ScrollStyle::ssBoth || mScrollBars == ScrollStyle::ssHorizontal) {
nMaxScroll = maxScrollWidth(); nMaxScroll = maxScrollWidth();
nMin = 1; nMin = 0;
nMax = nMaxScroll; nMax = nMaxScroll;
nPage = viewWidth(); nPage = viewWidth();
nPos = mLeftPos; nPos = mLeftPos;
@ -3144,7 +3144,7 @@ void QSynEdit::updateVScrollbar()
if (mScrollBars == ScrollStyle::ssBoth || mScrollBars == ScrollStyle::ssVertical) { if (mScrollBars == ScrollStyle::ssBoth || mScrollBars == ScrollStyle::ssVertical) {
nMaxScroll = maxScrollHeight(); nMaxScroll = maxScrollHeight();
nMin = 1; nMin = 0;
nMax = std::max(1, nMaxScroll); nMax = std::max(1, nMaxScroll);
nPage = mLinesInWindow; nPage = mLinesInWindow;
nPos = mTopPos; nPos = mTopPos;
@ -6458,9 +6458,9 @@ void QSynEdit::dragLeaveEvent(QDragLeaveEvent *)
int QSynEdit::maxScrollHeight() const int QSynEdit::maxScrollHeight() const
{ {
if (mOptions.testFlag(eoScrollPastEof)) if (mOptions.testFlag(eoScrollPastEof))
return std::max(displayLineCount(),1) * mTextHeight - 1; return (std::max(displayLineCount(),1) - 1) * mTextHeight;
else else
return std::max((displayLineCount()-mLinesInWindow+1) * mTextHeight - 1 , 1) ; return std::max((displayLineCount()-mLinesInWindow+1) * mTextHeight, 1) ;
} }
bool QSynEdit::modified() const bool QSynEdit::modified() const