Skip to content

Commit

Permalink
Improve text selection after Replace All In Selection operation
Browse files Browse the repository at this point in the history
Fix #9270, close #9273
  • Loading branch information
sasumner authored and donho committed Dec 18, 2020
1 parent 0546f75 commit 8f38707
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 4 deletions.
20 changes: 17 additions & 3 deletions PowerEditor/src/ScitillaComponent/FindReplaceDlg.cpp
Expand Up @@ -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<int>((*_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)
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);

Expand Down
1 change: 0 additions & 1 deletion PowerEditor/src/ScitillaComponent/FindReplaceDlg_rc.h
Expand Up @@ -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
Expand Down

0 comments on commit 8f38707

Please sign in to comment.