diff --git a/PowerEditor/src/NppIO.cpp b/PowerEditor/src/NppIO.cpp index 7a5cc0054..8feb03628 100644 --- a/PowerEditor/src/NppIO.cpp +++ b/PowerEditor/src/NppIO.cpp @@ -453,6 +453,18 @@ bool Notepad_plus::doReload(BufferID id, bool alert) bool Notepad_plus::doSave(BufferID id, const TCHAR * filename, bool isCopy) { + const int index = MainFileManager->getBufferIndexByID(id); + if (index == -1) + { + _nativeLangSpeaker.messageBox("BufferInvalidWarning", + _pPublicInterface->getHSelf(), + TEXT("Cannot save: Buffer is invalid."), + TEXT("Save failed"), + MB_OK | MB_ICONWARNING); + + return false; + } + SCNotification scnN; // Notify plugins that current file is about to be saved if (!isCopy)