diff --git a/PowerEditor/src/ScitillaComponent/FindReplaceDlg.cpp b/PowerEditor/src/ScitillaComponent/FindReplaceDlg.cpp index ec50803ab..009e51dc7 100644 --- a/PowerEditor/src/ScitillaComponent/FindReplaceDlg.cpp +++ b/PowerEditor/src/ScitillaComponent/FindReplaceDlg.cpp @@ -1223,12 +1223,6 @@ bool FindReplaceDlg::processFindNext(const TCHAR *txt2find, const FindOption *op // the text to find is modified so use the current position startPosition = cr.cpMin; endPosition = docLength; - } - else if (NextIncremental==pOptions->_incrementalType) - { - // text to find is not modified, so use current position +1 - startPosition = cr.cpMin; - endPosition = docLength; if (pOptions->_whichDirection == DIR_UP) { @@ -1237,6 +1231,19 @@ bool FindReplaceDlg::processFindNext(const TCHAR *txt2find, const FindOption *op endPosition = 0; } } + else if (NextIncremental==pOptions->_incrementalType) + { + // text to find is not modified, so use current position +1 + startPosition = cr.cpMin + 1; + endPosition = docLength; + + if (pOptions->_whichDirection == DIR_UP) + { + //When searching upwards, start is the lower part, end the upper, for backwards search + startPosition = cr.cpMax - 1; + endPosition = 0; + } + } int flags = Searching::buildSearchFlags(pOptions); switch (findNextType) @@ -1360,7 +1367,7 @@ bool FindReplaceDlg::processReplace(const TCHAR *txt2find, const TCHAR *txt2repl return false; FindOption replaceOptions = options ? *options : *_env; - replaceOptions._incrementalType = NextIncremental; + replaceOptions._incrementalType = FirstIncremental; if ((*_ppEditView)->getCurrentBuffer()->isReadOnly()) return false;