Skip to content

Commit

Permalink
+fix: regression: RegEx: find line start (^) previuos - skips empty l…
Browse files Browse the repository at this point in the history
…ines
  • Loading branch information
RaiKoHoff committed Mar 2, 2024
1 parent 4c2cdac commit 0002d6a
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions src/Edit.c
Original file line number Diff line number Diff line change
Expand Up @@ -7190,18 +7190,21 @@ bool EditFindNext(HWND hwnd, const LPEDITFINDREPLACE lpefr, bool bExtendSelectio
return false;
}
int const sFlags = (int)(lpefr->fuFlags);
bool const bIsRegExpr = (sFlags & SCFIND_REGEXP);

DocPos const iDocEndPos = Sci_GetDocEndPosition();

EditSetCaretToSelectionEnd(); // fluent switch between Prev/Next
DocPos start = SciCall_GetCurrentPos();
DocPos const curPos = SciCall_GetCurrentPos();
DocPos start = (curPos < iDocEndPos) ? curPos : 0;

DocPos end = iDocEndPos;

Sci_CallTipCancelEx();

DocPos iPos = _FindInTarget(wchFind, sFlags, &start, &end, true, FRMOD_NORM);

if ((iPos < NOT_FOUND) && (lpefr->fuFlags & SCFIND_REGEXP)) {
if ((iPos < NOT_FOUND) && bIsRegExpr) {
InfoBoxLng(MB_ICONWARNING, L"MsgInvalidRegex", IDS_MUI_REGEX_INVALID);
bSuppressNotFound = true;
} else if ((iPos < 0LL) && (start >= 0LL) && !bExtendSelection) {
Expand All @@ -7215,7 +7218,7 @@ bool EditFindNext(HWND hwnd, const LPEDITFINDREPLACE lpefr, bool bExtendSelectio
iPos = _FindInTarget(wchFind, sFlags, &start, &end, false, FRMOD_WRAPED);

if ((iPos < 0LL) || (end == _start)) {
if ((iPos < -1) && (lpefr->fuFlags & SCFIND_REGEXP)) {
if ((iPos < -1) && bIsRegExpr) {
InfoBoxLng(MB_ICONWARNING, L"MsgInvalidRegex", IDS_MUI_REGEX_INVALID);
bSuppressNotFound = true;
}
Expand Down Expand Up @@ -7289,19 +7292,20 @@ bool EditFindPrev(HWND hwnd, LPEDITFINDREPLACE lpefr, bool bExtendSelection, boo
return false;
}
int const sFlags = (int)(lpefr->fuFlags);
bool const bIsRegExpr = (sFlags & SCFIND_REGEXP);

DocPos const iDocEndPos = Sci_GetDocEndPosition();

EditSetCaretToSelectionStart(); // fluent switch between Next/Prev
DocPos const curPos = SciCall_GetCurrentPos();
DocPos start = (curPos > 0) ? SciCall_PositionBefore(curPos) : SciCall_PositionBefore(iDocEndPos);
DocPos start = (curPos > 0) ? (SciCall_IsSelectionEmpty() ? curPos : SciCall_PositionBefore(curPos)) : SciCall_PositionBefore(iDocEndPos);
DocPos end = 0LL;

Sci_CallTipCancelEx();

DocPos iPos = _FindInTarget(wchFind, sFlags, &start, &end, true, FRMOD_NORM);

if ((iPos < NOT_FOUND) && (sFlags & SCFIND_REGEXP)) {
if ((iPos < NOT_FOUND) && bIsRegExpr) {
InfoBoxLng(MB_ICONWARNING, L"MsgInvalidRegex", IDS_MUI_REGEX_INVALID);
bSuppressNotFound = true;
} else if ((iPos < 0LL) && (start <= iDocEndPos) && !bExtendSelection) {
Expand All @@ -7315,7 +7319,7 @@ bool EditFindPrev(HWND hwnd, LPEDITFINDREPLACE lpefr, bool bExtendSelection, boo
iPos = _FindInTarget(wchFind, sFlags, &start, &end, false, FRMOD_WRAPED);

if ((iPos < 0LL) || (start == _start)) {
if ((iPos < NOT_FOUND) && (sFlags & SCFIND_REGEXP)) {
if ((iPos < NOT_FOUND) && bIsRegExpr) {
InfoBoxLng(MB_ICONWARNING, L"MsgInvalidRegex", IDS_MUI_REGEX_INVALID);
bSuppressNotFound = true;
}
Expand Down

0 comments on commit 0002d6a

Please sign in to comment.