fix: indent line pos

change: align text with editor up-side when moving caret
This commit is contained in:
Roy Qu 2024-03-24 00:15:02 +08:00
parent 2dd570cb08
commit e1b716200d
2 changed files with 10 additions and 5 deletions

View File

@ -818,7 +818,7 @@ void QSynEditPainter::paintFoldAttributes()
break;
int X;
// Set vertical coord
int Y = (row - mEdit->yposToRow(0)) * mEdit->mTextHeight; // limit inside clip rect
int Y = (row-1) * mEdit->mTextHeight - mEdit->mTopPos; // limit inside clip rect
if (mEdit->mTextHeight % 2 == 1 && vLine % 2 == 0) {
Y++;
}

View File

@ -2986,7 +2986,11 @@ void QSynEdit::ensureCaretVisibleEx(bool ForceToMiddle)
if ((vCaretRow-1) * mTextHeight < mTopPos)
setTopPos( (vCaretRow - 1) * mTextHeight);
else if (vCaretRow * mTextHeight > mTopPos + clientHeight() ) {
setTopPos( vCaretRow * mTextHeight - clientHeight());
int value = vCaretRow * mTextHeight - clientHeight();
int offset = value % mTextHeight;
if (offset!=0)
value += (mTextHeight - offset);
setTopPos(value);
} else
setTopPos(mTopPos);
}
@ -6810,6 +6814,7 @@ void QSynEdit::setLeftPos(int value)
//int MaxVal;
//QRect iTextArea;
value = std::min(value,maxScrollWidth());
value = std::max(value, 0);
if (value != mLeftPos) {
horizontalScrollBar()->setValue(value);
setStatusChanged(StatusChange::scLeftPos);
@ -6829,7 +6834,7 @@ int QSynEdit::topPos() const
void QSynEdit::setTopPos(int value)
{
value = std::min(value,maxScrollHeight());
value = std::max(value, 1);
value = std::max(value, 0);
if (value != mTopPos) {
verticalScrollBar()->setValue(value);
setStatusChanged(StatusChange::scTopPos);