From 00736ea73be5e44f7997fad77867377ec9416013 Mon Sep 17 00:00:00 2001 From: Roy Qu Date: Mon, 23 Oct 2023 17:36:10 +0800 Subject: [PATCH] - change: Ensure the line just below caret is visible while moving caret. --- NEWS.md | 1 + RedPandaIDE/editor.cpp | 1 + libs/qsynedit/qsynedit/qsynedit.cpp | 8 ++++---- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/NEWS.md b/NEWS.md index 4aa885e3..5de2adb5 100644 --- a/NEWS.md +++ b/NEWS.md @@ -12,6 +12,7 @@ Red Panda C++ Version 2.26 - fix: Link in the project options dialog / precompiled header pages is not clickable. - change: Don't change caret position when ctrl+click. - 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 diff --git a/RedPandaIDE/editor.cpp b/RedPandaIDE/editor.cpp index ef792cd5..9454fb5e 100644 --- a/RedPandaIDE/editor.cpp +++ b/RedPandaIDE/editor.cpp @@ -1373,6 +1373,7 @@ void Editor::mouseReleaseEvent(QMouseEvent *event) QString filename = mParser->getHeaderFileName(mFilename,s); pMainWindow->openFile(filename); return; + } else if (mParser->enabled()) { gotoDefinition(p); return; diff --git a/libs/qsynedit/qsynedit/qsynedit.cpp b/libs/qsynedit/qsynedit/qsynedit.cpp index 44f06b16..6c60201c 100644 --- a/libs/qsynedit/qsynedit/qsynedit.cpp +++ b/libs/qsynedit/qsynedit/qsynedit.cpp @@ -3043,14 +3043,14 @@ void QSynEdit::ensureCursorPosVisibleEx(bool ForceToMiddle) // Make sure Y is visible int vCaretRow = displayY(); if (ForceToMiddle) { - if (vCaretRow < mTopLine || vCaretRow>(mTopLine + (mLinesInWindow - 1))) + if (vCaretRow < mTopLine || vCaretRow>(mTopLine + (mLinesInWindow - 2))) setTopLine( vCaretRow - (mLinesInWindow - 1) / 2); } else { if (vCaretRow < mTopLine) setTopLine(vCaretRow); - else if (vCaretRow > mTopLine + (mLinesInWindow - 1) && mLinesInWindow > 0) - setTopLine(vCaretRow - (mLinesInWindow - 1)); - else + else if (vCaretRow > mTopLine + (mLinesInWindow - 2) && mLinesInWindow > 2) { + setTopLine(vCaretRow - (mLinesInWindow - 2) ); + } else setTopLine(mTopLine); } }