diff --git a/PowerEditor/src/ScitillaComponent/FindReplaceDlg.cpp b/PowerEditor/src/ScitillaComponent/FindReplaceDlg.cpp index 08ccdaf5160..d424a3e5b3f 100644 --- a/PowerEditor/src/ScitillaComponent/FindReplaceDlg.cpp +++ b/PowerEditor/src/ScitillaComponent/FindReplaceDlg.cpp @@ -2023,7 +2023,23 @@ int FindReplaceDlg::processAll(ProcessOperation op, const FindOption *opt, bool findReplaceInfo._txt2replace = txt2replace; findReplaceInfo._startRange = startPosition; findReplaceInfo._endRange = endPosition; - return processRange(op, findReplaceInfo, pFindersInfo, pOptions, colourStyleID); + + int nbProcessed = processRange(op, findReplaceInfo, pFindersInfo, pOptions, colourStyleID); + + if (nbProcessed > 0 && op == ProcessReplaceAll && pOptions->_isInSelection) + { + int newDocLength = static_cast((*_ppEditView)->execute(SCI_GETLENGTH)); + endPosition += newDocLength - docLength; + (*_ppEditView)->execute(SCI_SETSELECTION, endPosition, startPosition); + (*_ppEditView)->execute(SCI_SCROLLRANGE, startPosition, endPosition); + if (startPosition == endPosition) + { + setChecked(IDC_IN_SELECTION_CHECK, false); + enableFindDlgItem(IDC_IN_SELECTION_CHECK, false); + } + } + + return nbProcessed; } int FindReplaceDlg::processRange(ProcessOperation op, FindReplaceInfo & findReplaceInfo, const FindersInfo * pFindersInfo, const FindOption *opt, int colourStyleID, ScintillaEditView *view2Process) @@ -2651,7 +2667,6 @@ void FindReplaceDlg::enableReplaceFunc(bool isEnable) showFindDlgItem(IDREPLACE, isEnable); showFindDlgItem(IDREPLACEWITH, isEnable); showFindDlgItem(IDREPLACEALL, isEnable); - showFindDlgItem(IDREPLACEINSEL, isEnable); showFindDlgItem(IDC_REPLACE_OPENEDFILES, isEnable); showFindDlgItem(IDC_REPLACEINSELECTION); showFindDlgItem(IDC_IN_SELECTION_CHECK); @@ -3260,7 +3275,6 @@ void FindReplaceDlg::enableMarkFunc() showFindDlgItem(IDREPLACE, false); showFindDlgItem(IDREPLACEWITH, false); showFindDlgItem(IDREPLACEALL, false); - showFindDlgItem(IDREPLACEINSEL, false); showFindDlgItem(IDC_REPLACE_OPENEDFILES, false); showFindDlgItem(IDC_REPLACEINSELECTION, false); diff --git a/PowerEditor/src/ScitillaComponent/FindReplaceDlg_rc.h b/PowerEditor/src/ScitillaComponent/FindReplaceDlg_rc.h index d1509ca2b82..93d22727ba5 100644 --- a/PowerEditor/src/ScitillaComponent/FindReplaceDlg_rc.h +++ b/PowerEditor/src/ScitillaComponent/FindReplaceDlg_rc.h @@ -44,7 +44,6 @@ #define IDUNSLASH 1607 #define IDREPLACE 1608 #define IDREPLACEALL 1609 -#define IDREPLACEINSEL 1610 #define ID_STATICTEXT_REPLACE 1611 //#define IDDIRECTIONUP 1612 //#define IDDIRECTIONDOWN 1613