diff --git a/src/Edit.c b/src/Edit.c index 152440314..05c7e62e7 100644 --- a/src/Edit.c +++ b/src/Edit.c @@ -4741,15 +4741,10 @@ static RegExResult_t __fastcall _FindHasMatch(HWND hwnd, LPCEDITFINDREPLACE lpef // static void __fastcall _SetTimerMarkAll(HWND hwnd, int delay) { - if (TEST_AND_RESET(BIT_TIMER_MARK_OCC)) { - TEST_AND_SET(BIT_TIMER_MARK_OCC); // in progress - return; - } - - TEST_AND_SET(BIT_TIMER_MARK_OCC); // raise flag to swollow next calls + TEST_AND_SET(BIT_TIMER_MARK_OCC); // flag to swollow multi-timer calls if (delay < USER_TIMER_MINIMUM) { - SendMessage(hwnd, WM_TIMER, MAKELONG(IDT_TIMER_MRKALL, 1), 0); // direct timer event + PostMessage(hwnd, WM_TIMER, MAKELONG(IDT_TIMER_MRKALL, 1), 0); // direct timer event } else { SetTimer(hwnd, IDT_TIMER_MRKALL, delay, NULL); @@ -4973,30 +4968,30 @@ INT_PTR CALLBACK EditFindReplaceDlgProcW(HWND hwnd,UINT umsg,WPARAM wParam,LPARA // The KillTimer function does not remove WM_TIMER messages already posted to the message queue. if (LOWORD(wParam) == IDT_TIMER_MRKALL) { - KillTimer(hwnd, IDT_TIMER_MRKALL); - if (!TEST_AND_RESET(BIT_MARK_OCC_IN_PROGRESS)) // stay in progress - { - TEST_AND_SET(BIT_MARK_OCC_IN_PROGRESS); // start progress - iMarkOccurrencesCount = 0; - _SetSearchFlags(hwnd, lpefr); - if (lpefr->bMarkOccurences) { - if (bFlagsChanged || (StringCchCompareXA(g_lastFind, lpefr->szFind) != 0)) { - StringCchCopyA(g_lastFind, COUNTOF(g_lastFind), lpefr->szFind); - RegExResult_t match = _FindHasMatch(g_hwndEdit, lpefr, (lpefr->bMarkOccurences), false); - if (regexMatch != match) { - regexMatch = match; + if (TEST_AND_RESET(BIT_TIMER_MARK_OCC)) { + KillTimer(hwnd, IDT_TIMER_MRKALL); + if (!TEST_AND_SET(BIT_MARK_OCC_IN_PROGRESS)) + { + iMarkOccurrencesCount = 0; + _SetSearchFlags(hwnd, lpefr); + if (lpefr->bMarkOccurences) { + if (bFlagsChanged || (StringCchCompareXA(g_lastFind, lpefr->szFind) != 0)) { + StringCchCopyA(g_lastFind, COUNTOF(g_lastFind), lpefr->szFind); + RegExResult_t match = _FindHasMatch(g_hwndEdit, lpefr, (lpefr->bMarkOccurences), false); + if (regexMatch != match) { + regexMatch = match; + } + // we have to set Sci's regex instance to first find (have substitution in place) + _FindHasMatch(g_hwndEdit, lpefr, false, true); + bFlagsChanged = false; + InvalidateRect(GetDlgItem(hwnd, IDC_FINDTEXT), NULL, true); + UpdateToolbar(); + UpdateStatusbar(); } - // we have to set Sci's regex instance to first find (have substitution in place) - _FindHasMatch(g_hwndEdit, lpefr, false, true); - bFlagsChanged = false; - InvalidateRect(GetDlgItem(hwnd, IDC_FINDTEXT), NULL, true); - UpdateToolbar(); - UpdateStatusbar(); } + TEST_AND_RESET(BIT_MARK_OCC_IN_PROGRESS); // done } - TEST_AND_RESET(BIT_MARK_OCC_IN_PROGRESS); // done } - TEST_AND_RESET(BIT_TIMER_MARK_OCC); // ready for new events return true; } } diff --git a/src/Notepad3.c b/src/Notepad3.c index 558a4116e..dfba2ad5e 100644 --- a/src/Notepad3.c +++ b/src/Notepad3.c @@ -1082,26 +1082,26 @@ LRESULT CALLBACK MainWndProc(HWND hwnd,UINT umsg,WPARAM wParam,LPARAM lParam) // The KillTimer function does not remove WM_TIMER messages already posted to the message queue. if (LOWORD(wParam) == IDT_TIMER_MAIN_MRKALL) { - KillTimer(hwnd, IDT_TIMER_MAIN_MRKALL); - if (!TEST_AND_RESET(BIT_MARK_OCC_IN_PROGRESS)) // stay in progress - { - TEST_AND_SET(BIT_MARK_OCC_IN_PROGRESS); // start progress - EditMarkAllOccurrences(); - TEST_AND_RESET(BIT_MARK_OCC_IN_PROGRESS); // done + if (TEST_AND_RESET(BIT_TIMER_MARK_OCC)) { + KillTimer(hwnd, IDT_TIMER_MAIN_MRKALL); + if (!TEST_AND_SET(BIT_MARK_OCC_IN_PROGRESS)) + { + EditMarkAllOccurrences(); + TEST_AND_RESET(BIT_MARK_OCC_IN_PROGRESS); // done + } } - TEST_AND_RESET(BIT_TIMER_MARK_OCC); // ready for new events return true; } else if (LOWORD(wParam) == IDT_TIMER_UPDATE_HOTSPOT) { - KillTimer(hwnd, IDT_TIMER_UPDATE_HOTSPOT); - if (!TEST_AND_RESET(BIT_UPDATE_HYPER_IN_PROGRESS)) // stay in progress - { - TEST_AND_SET(BIT_UPDATE_HYPER_IN_PROGRESS); // start progress - EditUpdateVisibleUrlHotspot(bHyperlinkHotspot); - TEST_AND_RESET(BIT_UPDATE_HYPER_IN_PROGRESS); // done + if (TEST_AND_RESET(BIT_TIMER_UPDATE_HYPER)) { + KillTimer(hwnd, IDT_TIMER_UPDATE_HOTSPOT); + if (!TEST_AND_SET(BIT_UPDATE_HYPER_IN_PROGRESS)) + { + EditUpdateVisibleUrlHotspot(bHyperlinkHotspot); + TEST_AND_RESET(BIT_UPDATE_HYPER_IN_PROGRESS); // done + } } - TEST_AND_RESET(BIT_TIMER_UPDATE_HYPER); // ready for new events return true; } } @@ -7064,15 +7064,10 @@ int CreateIniFileEx(LPCWSTR lpszIniFile) { // void MarkAllOccurrences(int delay) { - if (TEST_AND_RESET(BIT_TIMER_MARK_OCC)) { - TEST_AND_SET(BIT_TIMER_MARK_OCC); // in progress - return; - } - TEST_AND_SET(BIT_TIMER_MARK_OCC); // raise flag to swollow next calls if (delay < USER_TIMER_MINIMUM) { - SendMessage(g_hwndMain, WM_TIMER, MAKELONG(IDT_TIMER_MAIN_MRKALL, 1), 0); // direct timer event + PostMessage(g_hwndMain, WM_TIMER, MAKELONG(IDT_TIMER_MAIN_MRKALL, 1), 0); // direct timer event } else { SetTimer(g_hwndMain, IDT_TIMER_MAIN_MRKALL, delay, NULL); @@ -7086,15 +7081,10 @@ void MarkAllOccurrences(int delay) // void UpdateVisibleUrlHotspot(int delay) { - if (TEST_AND_RESET(BIT_TIMER_UPDATE_HYPER)) { - TEST_AND_SET(BIT_TIMER_UPDATE_HYPER); // in progress - return; - } - TEST_AND_SET(BIT_TIMER_UPDATE_HYPER); // raise flag to swollow next calls if (delay < USER_TIMER_MINIMUM) { - SendMessage(g_hwndMain, WM_TIMER, MAKELONG(IDT_TIMER_UPDATE_HOTSPOT, 1), 0); // direct timer event + PostMessage(g_hwndMain, WM_TIMER, MAKELONG(IDT_TIMER_UPDATE_HOTSPOT, 1), 0); // direct timer event } else { SetTimer(g_hwndMain, IDT_TIMER_UPDATE_HOTSPOT, delay, NULL);