diff options
author | Zufu Liu <unknown> | 2023-12-14 14:44:11 +1100 |
---|---|---|
committer | Zufu Liu <unknown> | 2023-12-14 14:44:11 +1100 |
commit | 361218f4984d429c1a518cb1dbd94612eab0ecaa (patch) | |
tree | 4efa7cfc7b09022b9419aae013de5aa28bbb5278 /src | |
parent | 108dbd549a2a7e17b744d13b451c0a18503b4480 (diff) | |
download | scintilla-mirror-361218f4984d429c1a518cb1dbd94612eab0ecaa.tar.gz |
Bug [#2405]. Fix regular expression bug in reverse direction where shortened
match returned.
Diffstat (limited to 'src')
-rw-r--r-- | src/Document.cxx | 37 |
1 files changed, 17 insertions, 20 deletions
diff --git a/src/Document.cxx b/src/Document.cxx index e6521df45..dcb087930 100644 --- a/src/Document.cxx +++ b/src/Document.cxx @@ -3269,34 +3269,31 @@ Sci::Position BuiltinRegex::FindText(Document *doc, Sci::Position minPos, Sci::P search.SetLineRange(lineStartPos, lineEndPos); int success = search.Execute(di, startOfLine, endOfLine); if (success) { - pos = search.bopat[0]; // Ensure only whole characters selected - search.eopat[0] = doc->MovePositionOutsideChar(search.eopat[0], 1, false); - lenRet = search.eopat[0] - search.bopat[0]; + Sci::Position endPos = doc->MovePositionOutsideChar(search.eopat[0], 1, false); // There can be only one start of a line, so no need to look for last match in line if ((resr.increment == -1) && !searchforLineStart) { // Check for the last match on this line. - int repetitions = 1000; // Break out of infinite loop - RESearch::MatchPositions bopat{}; - RESearch::MatchPositions eopat{}; - while (success && (search.eopat[0] <= endOfLine) && (repetitions--)) { - bopat = search.bopat; - eopat = search.eopat; - success = search.Execute(di, pos+1, endOfLine); + while (success && (endPos < endOfLine)) { + const RESearch::MatchPositions bopat = search.bopat; + const RESearch::MatchPositions eopat = search.eopat; + pos = endPos; + if (pos == bopat[0]) { + // empty match + pos = doc->NextPosition(pos, 1); + } + success = search.Execute(di, pos, endOfLine); if (success) { - if (search.eopat[0] <= minPos) { - pos = search.bopat[0]; - lenRet = search.eopat[0] - search.bopat[0]; - } else { - success = 0; - } + endPos = doc->MovePositionOutsideChar(search.eopat[0], 1, false); + } else { + search.bopat = bopat; + search.eopat = eopat; } } - if (!success) { - search.bopat = bopat; - search.eopat = eopat; - } } + search.eopat[0] = endPos; + pos = search.bopat[0]; + lenRet = endPos - pos; break; } } |