diff --git a/src/Edit.c b/src/Edit.c index b489eff21..1d2718029 100644 --- a/src/Edit.c +++ b/src/Edit.c @@ -87,8 +87,9 @@ extern BOOL bAccelWordNavigation; extern BOOL bDenyVirtualSpaceAccess; extern BOOL bHyperlinkHotspot; -extern int iMarkOccurrences; -extern int iMarkOccurrencesCount; +extern int iMarkOccurrences; +extern int iMarkOccurrencesCount; +extern int iMarkOccurrencesMaxCount; extern BOOL bMarkOccurrencesMatchVisible; extern NP2ENCODING mEncoding[]; @@ -5499,7 +5500,6 @@ void EditClearAllMarks(HWND hwnd, int iRangeStart, int iRangeEnd) } SendMessage(hwnd, SCI_SETINDICATORCURRENT, INDIC_NP3_MARK_OCCURANCE, 0); SendMessage(hwnd, SCI_INDICATORCLEARRANGE, iRangeStart, iRangeEnd); - iMarkOccurrencesCount = -1; // -1 ! } @@ -5586,6 +5586,8 @@ void EditMarkAll(HWND hwnd, char* pszFind, int flags, int rangeStart, int rangeE int start = rangeStart; int end = rangeEnd; + + iMarkOccurrencesCount = 0; SendMessage(hwnd, SCI_SETINDICATORCURRENT, INDIC_NP3_MARK_OCCURANCE, 0); int iPos = -1; @@ -5593,8 +5595,6 @@ void EditMarkAll(HWND hwnd, char* pszFind, int flags, int rangeStart, int rangeE iPos = EditFindInTarget(hwnd, pszText, iFindLength, flags, &start, &end, (start == iPos)); - ++iMarkOccurrencesCount; // -1 -> 0 - if (iPos < 0) break; // not found @@ -5607,7 +5607,7 @@ void EditMarkAll(HWND hwnd, char* pszFind, int flags, int rangeStart, int rangeE start = end; end = rangeEnd; - } while (start < end); // < iMarkOccurrencesMaxCount + } while ((start < end) && (++iMarkOccurrencesCount < iMarkOccurrencesMaxCount)); } } diff --git a/src/Notepad3.c b/src/Notepad3.c index 20f3a2b9f..4b2ca5a7b 100644 --- a/src/Notepad3.c +++ b/src/Notepad3.c @@ -150,6 +150,7 @@ BOOL bShowSelectionMargin; BOOL bShowLineNumbers; int iMarkOccurrences; int iMarkOccurrencesCount; +int iMarkOccurrencesMaxCount; BOOL bMarkOccurrencesMatchVisible; BOOL bMarkOccurrencesMatchCase; BOOL bMarkOccurrencesMatchWords; @@ -1043,6 +1044,7 @@ HWND InitInstance(HINSTANCE hInstance,LPSTR pszCmdLine,int nCmdShow) if (flagStartAsTrayIcon) SetNotifyIconTitle(g_hwndMain); + iMarkOccurrencesCount = 0; UpdateToolbar(); UpdateStatusbar(); UpdateLineNumberWidth(); @@ -6228,10 +6230,9 @@ void LoadSettings() iSciFontQuality = IniSectionGetInt(pIniSection,L"SciFontQuality", FontQuality[3]); iSciFontQuality = max(min(iSciFontQuality, 3), 0); - iMarkOccurrencesCount = -1; - //iMarkOccurrencesMaxCount = IniSectionGetInt(pIniSection,L"MarkOccurrencesMaxCount",2000); - //iMarkOccurrencesMaxCount = max(min(iMarkOccurrencesMaxCount,100000),2); - + iMarkOccurrencesMaxCount = IniSectionGetInt(pIniSection,L"MarkOccurrencesMaxCount",2000); + iMarkOccurrencesMaxCount = (iMarkOccurrencesMaxCount <= 0) ? INT_MAX : iMarkOccurrencesMaxCount; + bDenyVirtualSpaceAccess = IniSectionGetBool(pIniSection, L"DenyVirtualSpaceAccess", FALSE); bUseOldStyleBraceMatching = IniSectionGetBool(pIniSection, L"UseOldStyleBraceMatching", FALSE); @@ -7270,16 +7271,23 @@ void UpdateStatusbar() StringCchCopy(tchSel, COUNTOF(tchSel), L"--"); } - if ((iMarkOccurrencesCount > 0) && !bMarkOccurrencesMatchVisible) { - StringCchPrintf(tchOcc, COUNTOF(tchOcc), L"%i", iMarkOccurrencesCount); - FormatNumberStr(tchOcc); + // Print number of occurrence marks found + if ((iMarkOccurrencesCount > 0) && !bMarkOccurrencesMatchVisible) + { + if ((iMarkOccurrencesMaxCount < 0) || (iMarkOccurrencesCount < iMarkOccurrencesMaxCount)) + { + StringCchPrintf(tchOcc, COUNTOF(tchOcc), L"%i", iMarkOccurrencesCount); + FormatNumberStr(tchOcc); + } + else { + StringCchPrintf(tchOcc, COUNTOF(tchOcc), L">= %i", iMarkOccurrencesMaxCount); + } } else { StringCchCopy(tchOcc, COUNTOF(tchOcc), L"--"); } // Print number of selected lines in statusbar - const int iLineStart = SciCall_LineFromPosition(iSelStart); const int iLineEnd = SciCall_LineFromPosition(iSelEnd); const int iStartOfLinePos = SciCall_PositionFromLine(iLineEnd);