diff options
-rw-r--r-- | src/Document.cxx | 38 | ||||
-rw-r--r-- | win32/makefile | 2 |
2 files changed, 29 insertions, 11 deletions
diff --git a/src/Document.cxx b/src/Document.cxx index 745812044..f357cd3c7 100644 --- a/src/Document.cxx +++ b/src/Document.cxx @@ -855,14 +855,15 @@ long Document::FindText(int minPos, int maxPos, const char *s, int startPos; int endPos; + int increment = (minPos <= maxPos) ? 1 : -1; - if (minPos <= maxPos) { +// if (minPos <= maxPos) { startPos = minPos; endPos = maxPos; - } else { - startPos = maxPos; - endPos = minPos; - } +// } else { +// startPos = maxPos; +// endPos = minPos; +// } // Range endpoints should not be inside DBCS characters, but just in case, move them. startPos = MovePositionOutsideChar(startPos, 1, false); @@ -878,7 +879,9 @@ long Document::FindText(int minPos, int maxPos, const char *s, // Replace: $(\1-\2) int lineRangeStart = LineFromPosition(startPos); int lineRangeEnd = LineFromPosition(endPos); - if ((startPos >= LineEnd(lineRangeStart)) && (lineRangeStart < lineRangeEnd)) { + if ((increment == 1) && + (startPos >= LineEnd(lineRangeStart)) && + (lineRangeStart < lineRangeEnd)) { // the start position is at end of line or between line end characters. lineRangeStart++; startPos = LineStart(lineRangeStart); @@ -886,7 +889,7 @@ long Document::FindText(int minPos, int maxPos, const char *s, int pos = -1; int lenRet = 0; char searchEnd = s[*length - 1]; - if (*length == 1) { + if ((increment == 1) && (*length == 1)) { // These produce empty selections so nudge them on if needed if (s[0] == '^') { if (startPos == LineStart(lineRangeStart)) @@ -898,15 +901,16 @@ long Document::FindText(int minPos, int maxPos, const char *s, lineRangeStart = LineFromPosition(startPos); lineRangeEnd = LineFromPosition(endPos); } - for (int line = lineRangeStart; line <= lineRangeEnd; line++) { + int lineRangeBreak = lineRangeEnd + increment; + for (int line = lineRangeStart; line != lineRangeBreak; line += increment) { int startOfLine = LineStart(line); int endOfLine = LineEnd(line); - if (line == lineRangeStart) { + if ((increment == 1) && (line == lineRangeStart)) { if ((startPos != startOfLine) && (s[0] == '^')) continue; // Can't match start of line if start position after start of line startOfLine = startPos; } - if (line == lineRangeEnd) { + if ((increment == 1) && (line == lineRangeEnd)) { if ((endPos != endOfLine) && (searchEnd == '$')) continue; // Can't match end of line if end position before end of line endOfLine = endPos; @@ -916,6 +920,20 @@ long Document::FindText(int minPos, int maxPos, const char *s, if (success) { pos = pre->bopat[0]; lenRet = pre->eopat[0] - pre->bopat[0]; + if (increment == -1) { + // Check for the last match on this line. + while (success) { + success = pre->Execute(di, pos + 1, endOfLine); + if (success) { + if (pre->eopat[0] <= minPos) { + pos = pre->bopat[0]; + lenRet = pre->eopat[0] - pre->bopat[0]; + } else { + success = 0; + } + } + } + } break; } } diff --git a/win32/makefile b/win32/makefile index aa8943556..c9097c4f2 100644 --- a/win32/makefile +++ b/win32/makefile @@ -42,7 +42,7 @@ deps: LEXOBJS=\ LexAda.o LexAsm.o LexAVE.o LexBaan.o LexBullant.o LexConf.o LexCPP.o \ LexCrontab.o LexEiffel.o LexHTML.o LexLisp.o LexLua.o LexMatlab.o LexOthers.o \ -LexPascal.o LexPerl.o LexPython.o LexRuby.o LexSQL.o LexVB.o +LexPascal.o LexPerl.o LexPython.o LexRuby.o LexSQL.o LexVB.o #--Autogenerated -- end of automatically generated section SOBJS = ScintillaWin.o ScintillaBase.o Editor.o Document.o \ |