Skip to content

Commit

Permalink
Fix monitoring large file with frequent writes freezes UI issue
Browse files Browse the repository at this point in the history
  • Loading branch information
Brian C authored and donho committed Sep 6, 2024
1 parent 624e315 commit d5ec03a
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion PowerEditor/src/NppIO.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ DWORD WINAPI Notepad_plus::monitorFileOnChange(void * params)
case WAIT_OBJECT_0 + 1:
// We've received a notification in the queue.
{
bool bDoneOnce = false;
DWORD dwAction = 0;
wstring fn;
// Process all available changes, ignore User actions
Expand All @@ -93,7 +94,12 @@ DWORD WINAPI Notepad_plus::monitorFileOnChange(void * params)
{
if (dwAction == FILE_ACTION_MODIFIED)
{
::PostMessage(h, NPPM_INTERNAL_RELOADSCROLLTOEND, reinterpret_cast<WPARAM>(buf), 0);
if (!bDoneOnce)
{
::PostMessage(h, NPPM_INTERNAL_RELOADSCROLLTOEND, reinterpret_cast<WPARAM>(buf), 0);
bDoneOnce = true;
Sleep(250); // Limit refresh rate
}
}
else if ((dwAction == FILE_ACTION_REMOVED) || (dwAction == FILE_ACTION_RENAMED_OLD_NAME))
{
Expand Down

0 comments on commit d5ec03a

Please sign in to comment.