From 0002d6a596c0d3fc6be83c0b351d1eb7d7ec671d Mon Sep 17 00:00:00 2001 From: "METANEOCORTEX\\Kotti" Date: Sat, 2 Mar 2024 19:18:54 +0100 Subject: [PATCH] +fix: regression: RegEx: find line start (^) previuos - skips empty lines --- src/Edit.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/src/Edit.c b/src/Edit.c index ba77b1100..9966aec84 100644 --- a/src/Edit.c +++ b/src/Edit.c @@ -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) { @@ -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; } @@ -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) { @@ -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; }