Merge remote-tracking branch 'notepad3_orig_rizone/master' into Dev_NewFeatures

This commit is contained in:
Rainer Kottenhoff 2019-01-03 11:17:53 +01:00
commit cfb2cc36b8
2 changed files with 16 additions and 9 deletions

View File

@ -6181,11 +6181,11 @@ bool EditReplace(HWND hwnd, LPCEDITFINDREPLACE lpefr) {
_ENTER_TARGET_TRANSACTION_;
SciCall_TargetFromSelection();
SendMessage(hwnd, iReplaceMsg, (WPARAM)-1, (LPARAM)pszReplace);
Sci_ReplaceTarget(iReplaceMsg, -1, pszReplace);
// move caret behind replacement
const DocPos after = SciCall_GetTargetEnd();
DocPos const after = SciCall_GetTargetEnd();
SciCall_SetSel(after, after);
_LEAVE_TARGET_TRANSACTION_;
@ -6260,10 +6260,12 @@ int EditReplaceAllInRange(HWND hwnd, LPCEDITFINDREPLACE lpefr, DocPos iStartPos,
iPos = -1;
}
int iCount = utarray_len(ReplPosUTArray);
int const iCount = utarray_len(ReplPosUTArray);
if (iCount <= 0) { FreeMem(pszReplace); return 0; }
// === iterate over findings and replace strings ===
DocPos offset = 0;
DocPos searchStart = iStartPos;
DocPos totalReplLength = 0;
_IGNORE_NOTIFY_CHANGE_;
@ -6272,16 +6274,18 @@ int EditReplaceAllInRange(HWND hwnd, LPCEDITFINDREPLACE lpefr, DocPos iStartPos,
pPosPair = (ReplPos_t*)utarray_next(ReplPosUTArray, pPosPair)) {
// redo find to get group ranges filled
start = pPosPair->beg + offset;
end = iEndPos + offset;
start = searchStart;
end = iEndPos + totalReplLength;
iPos = _FindInTarget(hwnd, szFind, slen, (int)(lpefr->fuFlags), &start, &end, false, FRMOD_IGNORE);
_ENTER_TARGET_TRANSACTION_;
SciCall_SetTargetRange(start, end);
offset += ((DocPos)SendMessage(hwnd, iReplaceMsg, (WPARAM)-1, (LPARAM)pszReplace) - pPosPair->end + pPosPair->beg);
// SCI_REPLACETARGET or SCI_REPLACETARGETRE
DocPos const replLen = Sci_ReplaceTarget(iReplaceMsg, -1, pszReplace);
totalReplLength += replLen + pPosPair->beg - pPosPair->end;
searchStart = SciCall_GetTargetEnd();
_LEAVE_TARGET_TRANSACTION_;
}
@ -6292,7 +6296,7 @@ int EditReplaceAllInRange(HWND hwnd, LPCEDITFINDREPLACE lpefr, DocPos iStartPos,
utarray_free(ReplPosUTArray);
FreeMem(pszReplace);
*enlargement = offset;
*enlargement = totalReplLength;
return iCount;
}

View File

@ -214,6 +214,7 @@ DeclareSciCallR0(GetTargetEnd, GETTARGETEND, DocPos)
DeclareSciCallV0(TargetFromSelection, TARGETFROMSELECTION)
DeclareSciCallV2(SetTargetRange, SETTARGETRANGE, DocPos, start, DocPos, end)
DeclareSciCallR2(ReplaceTarget, REPLACETARGET, DocPos, DocPos, length, const char*, text)
DeclareSciCallR2(ReplaceTargetRe, REPLACETARGETRE, DocPos, DocPos, length, const char*, text)
DeclareSciCallV2(AddText, ADDTEXT, DocPos, length, const char*, text)
@ -502,6 +503,8 @@ inline DocPos Sci_GetRangeMaxLineLength(DocLn iBeginLine, DocLn iEndLine) {
return iMaxLineLen;
}
#define Sci_ReplaceTarget(M,L,T) (((M) == SCI_REPLACETARGET) ? SciCall_ReplaceTarget((L),(T)) : SciCall_ReplaceTargetRe((L),(T)))
//=============================================================================
#endif //_NP3_SCICALL_H_