diff --git a/PowerEditor/src/NppIO.cpp b/PowerEditor/src/NppIO.cpp index 9c2dc6739..019f17147 100644 --- a/PowerEditor/src/NppIO.cpp +++ b/PowerEditor/src/NppIO.cpp @@ -1007,7 +1007,15 @@ bool Notepad_plus::fileClose(BufferID id, int curView) bufferID = _pEditView->getCurrentBufferID(); Buffer * buf = MainFileManager.getBufferByID(bufferID); - if (buf->isUntitled() && buf->docLength() == 0) + int viewToClose = currentView(); + if (curView != -1) + viewToClose = curView; + + // Determinate if it's a cloned buffer + DocTabView* nonCurrentTab = (viewToClose == MAIN_VIEW) ? &_subDocTab : &_mainDocTab; + bool isCloned = nonCurrentTab->getIndexByBuffer(bufferID) != -1; + + if ((buf->isUntitled() && buf->docLength() == 0) || isCloned) { // Do nothing } @@ -1031,12 +1039,12 @@ bool Notepad_plus::fileClose(BufferID id, int curView) } } - int viewToClose = currentView(); - if (curView != -1) - viewToClose = curView; - bool isSnapshotMode = NppParameters::getInstance().getNppGUI().isSnapshotMode(); - doClose(bufferID, viewToClose, isSnapshotMode); + bool doDeleteBackup = isSnapshotMode; + if (isSnapshotMode && isCloned) // if Buffer is cloned then we don't delete backup file + doDeleteBackup = false; + + doClose(bufferID, viewToClose, doDeleteBackup); return true; }