From 9a6614ea98837fdfa66ad06ae17dd56045a9aaf8 Mon Sep 17 00:00:00 2001 From: Don Ho Date: Wed, 21 Feb 2024 19:03:31 +0100 Subject: [PATCH] Enhance NPPN_GLOBALMODIFIED notification The commit enhances https://github.com/notepad-plus-plus/notepad-plus-plus/commit/49e6957d486c360e05ba85ceb1c179a891831779 --- PowerEditor/src/MISC/PluginsManager/Notepad_plus_msgs.h | 7 ++++--- PowerEditor/src/NppBigSwitch.cpp | 2 +- PowerEditor/src/ScintillaComponent/FindReplaceDlg.cpp | 5 +++-- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/PowerEditor/src/MISC/PluginsManager/Notepad_plus_msgs.h b/PowerEditor/src/MISC/PluginsManager/Notepad_plus_msgs.h index 90a517958..4071e07b4 100644 --- a/PowerEditor/src/MISC/PluginsManager/Notepad_plus_msgs.h +++ b/PowerEditor/src/MISC/PluginsManager/Notepad_plus_msgs.h @@ -1173,9 +1173,10 @@ enum Platform { PF_UNKNOWN, PF_X86, PF_X64, PF_IA64, PF_ARM64 }; //scnNotification->nmhdr.hwndFrom = hwndNpp; //scnNotification->nmhdr.idFrom = BufferID; //where pluginMessage is pointer of type wchar_t - #define NPPN_GLOBALMODIFIED (NPPN_FIRST + 30) // To notify plugins that the current document is just modified by Replace All action. For solving the performance issue (from v8.6.4), - // Notepad++ doesn't trigger SCN_MODIFIED & other Scitilla notifications during Replace All action anymore. - // Plugin devs should monitor NPPN_GLOBALMODIFIED instead. This notification is implemented in Notepad++ v8.6.5. + #define NPPN_GLOBALMODIFIED (NPPN_FIRST + 30) // To notify plugins that the current document is just modified by Replace All action. + // For solving the performance issue (from v8.6.4), Notepad++ doesn't trigger SCN_MODIFIED during Replace All action anymore. + // As a result, the plugins which monitor SCN_MODIFIED should also monitor NPPN_GLOBALMODIFIED. + // This notification is implemented in Notepad++ v8.6.5. //scnNotification->nmhdr.code = NPPN_GLOBALMODIFIED; //scnNotification->nmhdr.hwndFrom = BufferID; //scnNotification->nmhdr.idFrom = 0; // preserved for the future use, must be zero diff --git a/PowerEditor/src/NppBigSwitch.cpp b/PowerEditor/src/NppBigSwitch.cpp index 69e61699a..b4c352dca 100644 --- a/PowerEditor/src/NppBigSwitch.cpp +++ b/PowerEditor/src/NppBigSwitch.cpp @@ -3520,7 +3520,7 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT message, WPARAM wParam, LPARAM lPa { SCNotification scnN{}; scnN.nmhdr.code = NPPN_GLOBALMODIFIED; - scnN.nmhdr.hwndFrom = reinterpret_cast(_pEditView->getCurrentBuffer()); + scnN.nmhdr.hwndFrom = reinterpret_cast(wParam); scnN.nmhdr.idFrom = 0; _pluginsManager.notify(&scnN); return TRUE; diff --git a/PowerEditor/src/ScintillaComponent/FindReplaceDlg.cpp b/PowerEditor/src/ScintillaComponent/FindReplaceDlg.cpp index b7a436e3a..61f36aad3 100644 --- a/PowerEditor/src/ScintillaComponent/FindReplaceDlg.cpp +++ b/PowerEditor/src/ScintillaComponent/FindReplaceDlg.cpp @@ -2817,8 +2817,9 @@ int FindReplaceDlg::processAll(ProcessOperation op, const FindOption *opt, bool (*_ppEditView)->execute(SCI_SETMODEVENTMASK, notifFlag); if (op == ProcessReplaceAll && nbProcessed > 0) // All the notification of modification (SCN_MODIFIED) were removed during the operations, so we set modified status true here { - (*_ppEditView)->getCurrentBuffer()->setModifiedStatus(true); - ::SendMessage(_hParent, NPPM_INTERNAL_DOCMODIFIEDBYREPLACEALL, 0, 0); + Buffer* buf = (*_ppEditView)->getCurrentBuffer(); + buf->setModifiedStatus(true); + ::SendMessage(_hParent, NPPM_INTERNAL_DOCMODIFIEDBYREPLACEALL, reinterpret_cast(buf), 0); }