Fix Replace All action not notifying plugins of modification regression

Add NPPN_GLOBALMODIFIED to notify plugins that the current document is just modified by Replace All action.
	//scnNotification->nmhdr.code = NPPN_GLOBALMODIFIED;
	//scnNotification->nmhdr.hwndFrom = BufferID;
	//scnNotification->nmhdr.idFrom = 0; // preserved for the future use, must be zero

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.

Ref: https://github.com/notepad-plus-plus/notepad-plus-plus/pull/14685#issuecomment-1955229867

Fix #14767, close #14768
pull/14778/head
Don Ho 9 months ago
parent 120fc5d726
commit 49e6957d48

@ -1047,7 +1047,7 @@ enum Platform { PF_UNKNOWN, PF_X86, PF_X64, PF_IA64, PF_ARM64 };
//scnNotification->nmhdr.idFrom = BufferID;
#define NPPN_FILEBEFORESAVE (NPPN_FIRST + 7) // To notify plugins that the current file is about to be saved
//scnNotification->nmhdr.code = NPPN_FILEBEFOREOPEN;
//scnNotification->nmhdr.code = NPPN_FILEBEFORESAVE;
//scnNotification->nmhdr.hwndFrom = hwndNpp;
//scnNotification->nmhdr.idFrom = BufferID;
@ -1077,7 +1077,7 @@ enum Platform { PF_UNKNOWN, PF_X86, PF_X64, PF_IA64, PF_ARM64 };
//scnNotification->nmhdr.idFrom = currentBufferID;
#define NPPN_SHORTCUTREMAPPED (NPPN_FIRST + 13) // To notify plugins that plugin command shortcut is remapped.
//scnNotification->nmhdr.code = NPPN_SHORTCUTSREMAPPED;
//scnNotification->nmhdr.code = NPPN_SHORTCUTREMAPPED;
//scnNotification->nmhdr.hwndFrom = ShortcutKeyStructurePointer;
//scnNotification->nmhdr.idFrom = cmdID;
//where ShortcutKeyStructurePointer is pointer of struct ShortcutKey:
@ -1089,12 +1089,12 @@ enum Platform { PF_UNKNOWN, PF_X86, PF_X64, PF_IA64, PF_ARM64 };
//};
#define NPPN_FILEBEFORELOAD (NPPN_FIRST + 14) // To notify plugins that the current file is about to be loaded
//scnNotification->nmhdr.code = NPPN_FILEBEFOREOPEN;
//scnNotification->nmhdr.code = NPPN_FILEBEFORELOAD;
//scnNotification->nmhdr.hwndFrom = hwndNpp;
//scnNotification->nmhdr.idFrom = NULL;
#define NPPN_FILELOADFAILED (NPPN_FIRST + 15) // To notify plugins that file open operation failed
//scnNotification->nmhdr.code = NPPN_FILEOPENFAILED;
//scnNotification->nmhdr.code = NPPN_FILELOADFAILED;
//scnNotification->nmhdr.hwndFrom = hwndNpp;
//scnNotification->nmhdr.idFrom = BufferID;
@ -1172,3 +1172,10 @@ enum Platform { PF_UNKNOWN, PF_X86, PF_X64, PF_IA64, PF_ARM64 };
//scnNotification->nmhdr.code = NPPN_EXTERNALLEXERBUFFER;
//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.
//scnNotification->nmhdr.code = NPPN_GLOBALMODIFIED;
//scnNotification->nmhdr.hwndFrom = BufferID;
//scnNotification->nmhdr.idFrom = 0; // preserved for the future use, must be zero

@ -3516,6 +3516,16 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT message, WPARAM wParam, LPARAM lPa
return TRUE;
}
case NPPM_INTERNAL_DOCMODIFIEDBYREPLACEALL:
{
SCNotification scnN{};
scnN.nmhdr.code = NPPN_GLOBALMODIFIED;
scnN.nmhdr.hwndFrom = reinterpret_cast<void*>(_pEditView->getCurrentBuffer());
scnN.nmhdr.idFrom = 0;
_pluginsManager.notify(&scnN);
return TRUE;
}
default:
{
if (message == WDN_NOTIFY)

@ -2816,7 +2816,10 @@ int FindReplaceDlg::processAll(ProcessOperation op, const FindOption *opt, bool
// Turn ON the notifications after operations
(*_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);
}
if (nbProcessed == FIND_INVALID_REGULAR_EXPRESSION)
@ -4750,7 +4753,7 @@ void Finder::addSearchResultInfo(int count, int countSearched, bool searchedEnti
generic_string hitsIn = count == 1 ? TEXT("hit") : TEXT("hits");
generic_string fileOrSelection = searchedEntireNotSelection ? TEXT("file") : TEXT("selection");;
generic_string fileOrSelection = searchedEntireNotSelection ? TEXT("file") : TEXT("selection");
if (_nbFoundFiles != 1)
{
fileOrSelection += TEXT("s");

@ -1311,7 +1311,7 @@ int FindLongestLine(HDC hdc, wchar_t* text, SIZE* size)
{
int longest = 0;
wchar_t* buffer = nullptr;
wchar_t* token = WCSTOK(text, TEXT("\n"), &buffer);;
wchar_t* token = WCSTOK(text, TEXT("\n"), &buffer);
while (token)
{

@ -1385,7 +1385,7 @@ bool ShortcutMapper::findKeyConflicts(__inout_opt generic_string * const keyConf
*keyConflictLocation += TEXT(" | ");
*keyConflictLocation += std::to_wstring(itemIndex + 1);
*keyConflictLocation += TEXT(" ");
*keyConflictLocation += string2wstring(vShortcuts[itemIndex].getName(), CP_UTF8);;
*keyConflictLocation += string2wstring(vShortcuts[itemIndex].getName(), CP_UTF8);
*keyConflictLocation += TEXT(" ( ");
*keyConflictLocation += string2wstring(vShortcuts[itemIndex].toString(), CP_UTF8);
*keyConflictLocation += TEXT(" )");

@ -657,6 +657,7 @@
#define NPPM_INTERNAL_EXTERNALLEXERBUFFER (NOTEPADPLUS_USER_INTERNAL + 76)
#define NPPM_INTERNAL_CHECKUNDOREDOSTATE (NOTEPADPLUS_USER_INTERNAL + 77)
#define NPPM_INTERNAL_LINECUTCOPYWITHOUTSELECTION (NOTEPADPLUS_USER_INTERNAL + 78)
#define NPPM_INTERNAL_DOCMODIFIEDBYREPLACEALL (NOTEPADPLUS_USER_INTERNAL + 79)
// See Notepad_plus_msgs.h
//#define NOTEPADPLUS_USER (WM_USER + 1000)

Loading…
Cancel
Save