From 12983f5ae0ff0d642834f15bf2c9d8e9894df55e Mon Sep 17 00:00:00 2001 From: Roy Qu Date: Sat, 25 Feb 2023 22:30:34 +0800 Subject: [PATCH] - fix: Word on the last line's end can't be searched. --- NEWS.md | 1 + libs/qsynedit/qsynedit/qsynedit.cpp | 7 ++++--- libs/qsynedit/qsynedit/searcher/regexsearcher.cpp | 2 ++ 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/NEWS.md b/NEWS.md index a732585f..5e6078df 100644 --- a/NEWS.md +++ b/NEWS.md @@ -7,6 +7,7 @@ Red Panda C++ Version 2.15 - change: Default value for the debugger debugger panel "memory view's columns" is changed from 8 to 16. - change: Default value for the debugger debugger panel "memory view's rows" is changed from 8 to 16. - enhancement: Display hex value as ascii chars in the debugger panel memory view tab. + - fix: Word on the last line's end can't be searched. Red Panda C++ Version 2.14 diff --git a/libs/qsynedit/qsynedit/qsynedit.cpp b/libs/qsynedit/qsynedit/qsynedit.cpp index 7722a790..44c9565a 100644 --- a/libs/qsynedit/qsynedit/qsynedit.cpp +++ b/libs/qsynedit/qsynedit/qsynedit.cpp @@ -5173,7 +5173,7 @@ int QSynEdit::searchReplace(const QString &sSearch, const QString &sReplace, Sea // Is the search result entirely in the search range? bool isInValidSearchRange = true; int first = nFound; - int last = nFound + nSearchLen; + int last = nFound + nSearchLen -1; if ((mActiveSelectionMode == SelectionMode::Normal) || !sOptions.testFlag(ssoSelectedOnly)) { if (((ptCurrent.line == ptStart.line) && (first < ptStart.ch)) || @@ -5238,10 +5238,11 @@ int QSynEdit::searchReplace(const QString &sSearch, const QString &sReplace, Sea } // search next / previous line - if (bBackward) + if (bBackward) { ptCurrent.line--; - else + } else { ptCurrent.line++; + } if (((ptCurrent.line < ptStart.line) || (ptCurrent.line > ptEnd.line)) && bFromCursor ){ if (!sOptions.testFlag(ssoWrapAround) && confirmAroundCallback && !confirmAroundCallback()) diff --git a/libs/qsynedit/qsynedit/searcher/regexsearcher.cpp b/libs/qsynedit/qsynedit/searcher/regexsearcher.cpp index a9c2765c..1618b37e 100644 --- a/libs/qsynedit/qsynedit/searcher/regexsearcher.cpp +++ b/libs/qsynedit/qsynedit/searcher/regexsearcher.cpp @@ -53,6 +53,8 @@ int RegexSearcher::findAll(const QString &text) QRegularExpressionMatchIterator it = mRegex.globalMatch(text); while (it.hasNext()) { QRegularExpressionMatch match = it.next(); + if (match.capturedLength()==0) + continue; mLengths.append(match.capturedLength()); mResults.append(match.capturedStart()); }