From bcbcc6148146cf007959bbe8d763b9292c013e18 Mon Sep 17 00:00:00 2001 From: Roy Qu Date: Wed, 20 Mar 2024 20:42:20 +0800 Subject: [PATCH] - fix: Caret unseen when move to a long line end by press END. --- NEWS.md | 1 + libs/qsynedit/qsynedit/qsynedit.cpp | 20 ++++++++++---------- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/NEWS.md b/NEWS.md index 07404540..9f773432 100644 --- a/NEWS.md +++ b/NEWS.md @@ -61,6 +61,7 @@ Red Panda C++ Version 2.27 - enhancement: "Mouse scroll direction" option in Options / Editor / General - change: Invert scroll direction in horizontal, like in vertical. - enhancement: Show type completion info after 'const' and 'volatile' + - fix: Caret unseen when move to a long line end by press END. Red Panda C++ Version 2.26 - enhancement: Code suggestion for embedded std::vectors. diff --git a/libs/qsynedit/qsynedit/qsynedit.cpp b/libs/qsynedit/qsynedit/qsynedit.cpp index 677b0878..3afcfe27 100644 --- a/libs/qsynedit/qsynedit/qsynedit.cpp +++ b/libs/qsynedit/qsynedit/qsynedit.cpp @@ -266,14 +266,14 @@ void QSynEdit::setCaretXYEx(bool CallEnsureCursorPosVisible, BufferCoord value) if (CallEnsureCursorPosVisible) ensureCursorPosVisible(); } else { - // Also call UpdateLastCaretX if the caret didn't move. Apps don't know - // anything about fLastCaretX and they shouldn't need to. So, to avoid any - // unwanted surprises, always update fLastCaretX whenever CaretXY is - // assigned to. - // Note to SynEdit developers: If this is undesirable in some obscure - // case, just save the value of fLastCaretX before assigning to CaretXY and - // restore it afterward as appropriate. - updateLastCaretX(); + // Also call UpdateLastCaretX if the caret didn't move. Apps don't know + // anything about fLastCaretX and they shouldn't need to. So, to avoid any + // unwanted surprises, always update fLastCaretX whenever CaretXY is + // assigned to. + // Note to SynEdit developers: If this is undesirable in some obscure + // case, just save the value of fLastCaretX before assigning to CaretXY and + // restore it afterward as appropriate. + updateLastCaretX(); } } @@ -3063,8 +3063,8 @@ void QSynEdit::ensureCursorPosVisibleEx(bool ForceToMiddle) int visibleX = displayX(); if (visibleX < leftPos()) setLeftPos(visibleX); - else if (visibleX >= viewWidth() + leftPos() && viewWidth()>0) - setLeftPos(visibleX - viewWidth() + 1); + else if (visibleX > viewWidth() + leftPos() && viewWidth()>0) + setLeftPos(visibleX - viewWidth() + mCharWidth); else setLeftPos(leftPos()); // Make sure Y is visible