Fix closing unsaved clone document makes periodic backup lost issue

And change the behaviour of closing a cloned document: there's no more "Save or not" dialog appears.

Fix #8227, close #15409
This commit is contained in:
Don Ho 2024-07-07 05:06:39 +02:00
parent 439bbb04d2
commit ac67f15c2b
1 changed files with 14 additions and 6 deletions

View File

@ -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;
}