Improve text selection after Replace All In Selection operation

Fix #9270, close #9273
This commit is contained in:
Scott Sumner 2020-12-15 11:08:52 -05:00 committed by Don HO
parent 0546f75a71
commit 8f38707d33
No known key found for this signature in database
GPG Key ID: 6C429F1D8D84F46E
2 changed files with 17 additions and 4 deletions

View File

@ -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)
@ -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);

View File

@ -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