- change: Ensure the line just below caret is visible while moving caret.

This commit is contained in:
Roy Qu 2023-10-23 17:36:10 +08:00
parent 7b9c5b378a
commit 00736ea73b
3 changed files with 6 additions and 4 deletions

View File

@ -12,6 +12,7 @@ Red Panda C++ Version 2.26
- fix: Link in the project options dialog / precompiled header pages is not clickable. - fix: Link in the project options dialog / precompiled header pages is not clickable.
- change: Don't change caret position when ctrl+click. - change: Don't change caret position when ctrl+click.
- fix: Should cd to working directory when debugging. - fix: Should cd to working directory when debugging.
- change: Ensure the line just below caret is visible while moving caret.
Red Panda C++ Version 2.25 Red Panda C++ Version 2.25

View File

@ -1373,6 +1373,7 @@ void Editor::mouseReleaseEvent(QMouseEvent *event)
QString filename = mParser->getHeaderFileName(mFilename,s); QString filename = mParser->getHeaderFileName(mFilename,s);
pMainWindow->openFile(filename); pMainWindow->openFile(filename);
return; return;
} else if (mParser->enabled()) { } else if (mParser->enabled()) {
gotoDefinition(p); gotoDefinition(p);
return; return;

View File

@ -3043,14 +3043,14 @@ void QSynEdit::ensureCursorPosVisibleEx(bool ForceToMiddle)
// Make sure Y is visible // Make sure Y is visible
int vCaretRow = displayY(); int vCaretRow = displayY();
if (ForceToMiddle) { if (ForceToMiddle) {
if (vCaretRow < mTopLine || vCaretRow>(mTopLine + (mLinesInWindow - 1))) if (vCaretRow < mTopLine || vCaretRow>(mTopLine + (mLinesInWindow - 2)))
setTopLine( vCaretRow - (mLinesInWindow - 1) / 2); setTopLine( vCaretRow - (mLinesInWindow - 1) / 2);
} else { } else {
if (vCaretRow < mTopLine) if (vCaretRow < mTopLine)
setTopLine(vCaretRow); setTopLine(vCaretRow);
else if (vCaretRow > mTopLine + (mLinesInWindow - 1) && mLinesInWindow > 0) else if (vCaretRow > mTopLine + (mLinesInWindow - 2) && mLinesInWindow > 2) {
setTopLine(vCaretRow - (mLinesInWindow - 1)); setTopLine(vCaretRow - (mLinesInWindow - 2) );
else } else
setTopLine(mTopLine); setTopLine(mTopLine);
} }
} }