| 47 | } |
| 48 | |
| 49 | Sci_CharacterRange Finder::findNext(int startPos) |
| 50 | { |
| 51 | did_latest_search_wrap = false; |
| 52 | |
| 53 | if (text.isEmpty()) |
| 54 | return {INVALID_POSITION, INVALID_POSITION}; |
| 55 | |
| 56 | const int pos = startPos == INVALID_POSITION ? editor->selectionEnd() : startPos; |
| 57 | const QByteArray textData = text.toUtf8(); |
| 58 | |
| 59 | editor->setTargetRange(pos, editor->length()); |
| 60 | editor->setSearchFlags(search_flags); |
| 61 | |
| 62 | if (editor->searchInTarget(textData.length(), textData.constData()) != INVALID_POSITION) { |
| 63 | return {static_cast<Sci_PositionCR>(editor->targetStart()), static_cast<Sci_PositionCR>(editor->targetEnd())}; |
| 64 | } |
| 65 | else if (wrap) { |
| 66 | editor->setTargetRange(0, pos); |
| 67 | if (editor->searchInTarget(textData.length(), textData.constData()) != INVALID_POSITION) { |
| 68 | did_latest_search_wrap = true; |
| 69 | |
| 70 | return {static_cast<Sci_PositionCR>(editor->targetStart()), static_cast<Sci_PositionCR>(editor->targetEnd())}; |
| 71 | } |
| 72 | } |
| 73 | |
| 74 | return {INVALID_POSITION, INVALID_POSITION}; |
| 75 | } |
| 76 | |
| 77 | Sci_CharacterRange Finder::findPrev() |
| 78 | { |
no test coverage detected