From d5ec03a46458a1e014a5bfe820199b0d7d176688 Mon Sep 17 00:00:00 2001 From: Brian C Date: Mon, 2 Sep 2024 18:08:20 +0200 Subject: [PATCH] Fix monitoring large file with frequent writes freezes UI issue Fix #9661, close #15598 --- PowerEditor/src/NppIO.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/PowerEditor/src/NppIO.cpp b/PowerEditor/src/NppIO.cpp index b166a6138..70ea7568d 100644 --- a/PowerEditor/src/NppIO.cpp +++ b/PowerEditor/src/NppIO.cpp @@ -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 @@ -93,7 +94,12 @@ DWORD WINAPI Notepad_plus::monitorFileOnChange(void * params) { if (dwAction == FILE_ACTION_MODIFIED) { - ::PostMessage(h, NPPM_INTERNAL_RELOADSCROLLTOEND, reinterpret_cast(buf), 0); + if (!bDoneOnce) + { + ::PostMessage(h, NPPM_INTERNAL_RELOADSCROLLTOEND, reinterpret_cast(buf), 0); + bDoneOnce = true; + Sleep(250); // Limit refresh rate + } } else if ((dwAction == FILE_ACTION_REMOVED) || (dwAction == FILE_ACTION_RENAMED_OLD_NAME)) {