Fix rename tab error msg while no change tab name

Fix #16661, close #16665
This commit is contained in:
Don Ho 2025-06-11 16:16:37 +02:00
parent 299d7cb26e
commit 5b26ef1ca8

View File

@ -2085,6 +2085,9 @@ bool Notepad_plus::fileRename(BufferID bufferID)
wchar_t *tabNewName = reinterpret_cast<wchar_t *>(strDlg.doDialog()); wchar_t *tabNewName = reinterpret_cast<wchar_t *>(strDlg.doDialog());
if (tabNewName) if (tabNewName)
{ {
if (oldFileNamePath == tabNewName) // No change but user clicks on OK
return false;
wstring tabNewNameStr = tabNewName; wstring tabNewNameStr = tabNewName;
trim(tabNewNameStr); // No leading and trailing space allowed trim(tabNewNameStr); // No leading and trailing space allowed
@ -2110,10 +2113,12 @@ bool Notepad_plus::fileRename(BufferID bufferID)
L"Rename failed", L"Rename failed",
MB_OK | MB_ICONSTOP); MB_OK | MB_ICONSTOP);
} }
else else // The change will be done here
{ {
_pluginsManager.notify(&scnN); _pluginsManager.notify(&scnN); // send NPPN_FILEBEFORERENAME
buf->setFileName(tabNewNameStr.c_str()); buf->setFileName(tabNewNameStr.c_str());
scnN.nmhdr.code = NPPN_FILERENAMED; scnN.nmhdr.code = NPPN_FILERENAMED;
_pluginsManager.notify(&scnN); _pluginsManager.notify(&scnN);