From d31369f267d3d81b5bd533dd0e58053b8c334cc8 Mon Sep 17 00:00:00 2001 From: Don Ho Date: Sun, 24 Jul 2011 01:25:55 +0000 Subject: [PATCH] [BUG_FIXED] (Author:Alexander van der Lokken) Fix "Replace all" feature hangs on the Regular Expression '$'. git-svn-id: svn://svn.tuxfamily.org/svnroot/notepadplus/repository/trunk@795 f5eea248-9336-0410-98b8-ebc06183d4e3 --- PowerEditor/src/ScitillaComponent/FindReplaceDlg.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/PowerEditor/src/ScitillaComponent/FindReplaceDlg.cpp b/PowerEditor/src/ScitillaComponent/FindReplaceDlg.cpp index 0d951f910..91f21c45f 100644 --- a/PowerEditor/src/ScitillaComponent/FindReplaceDlg.cpp +++ b/PowerEditor/src/ScitillaComponent/FindReplaceDlg.cpp @@ -1639,6 +1639,12 @@ int FindReplaceDlg::processRange(ProcessOperation op, const TCHAR *txt2find, con } } + nbProcessed++; + + // After the processing of the last string occurence the search loop should be stopped + // This helps to avoid the endless replacement during the EOL ("$") searching + if( targetStart + foundTextLen == endRange ) + break; if (!foundTextLen && !replaceDelta) startRange = targetStart + foundTextLen + 1; // find a empty string so just step forword @@ -1646,8 +1652,6 @@ int FindReplaceDlg::processRange(ProcessOperation op, const TCHAR *txt2find, con startRange = targetStart + foundTextLen + replaceDelta; //search from result onwards endRange += replaceDelta; //adjust end of range in case of replace - nbProcessed++; - targetStart = (*_ppEditView)->searchInTarget(pTextFind, stringSizeFind, startRange, endRange); } delete [] pTextFind;