Skip save all warning dialg if only current editing file is dirty
Here is the behaviour of this commit: 1. If there's only one file dirty, and it's current editing one, then SaveAll dialog won't display. 2. If there's only one file dirty, and it's NOT current editing one, then SaveAll dialog WILL display. 3. If there's 1 editing file which is dirty, and its clone (dirty also) is on the other view, then SaveAll dialog WILL display. Fix #10995
This commit is contained in:
parent
d1347d5014
commit
d0b2a9ff9d
|
@ -154,7 +154,7 @@ public:
|
|||
|
||||
void setTitle();
|
||||
void getTaskListInfo(TaskListInfo *tli);
|
||||
|
||||
size_t getNbDirtyBuffer(int view);
|
||||
// For filtering the modeless Dialog message
|
||||
|
||||
//! \name File Operations
|
||||
|
|
|
@ -1636,9 +1636,41 @@ bool Notepad_plus::fileSaveAllConfirm()
|
|||
return confirmed;
|
||||
}
|
||||
|
||||
size_t Notepad_plus::getNbDirtyBuffer(int view)
|
||||
{
|
||||
if (view != MAIN_VIEW && view != SUB_VIEW)
|
||||
return 0;
|
||||
DocTabView* pDocTabView = &_mainDocTab;
|
||||
if (view == SUB_VIEW)
|
||||
pDocTabView = &_subDocTab;
|
||||
|
||||
size_t count = 0;
|
||||
for (size_t i = 0; i < pDocTabView->nbItem(); ++i)
|
||||
{
|
||||
BufferID id = pDocTabView->getBufferByIndex(i);
|
||||
Buffer* buf = MainFileManager.getBufferByID(id);
|
||||
|
||||
if (buf->isDirty())
|
||||
{
|
||||
++count;
|
||||
}
|
||||
}
|
||||
return count;
|
||||
}
|
||||
|
||||
bool Notepad_plus::fileSaveAll()
|
||||
{
|
||||
if ( fileSaveAllConfirm() )
|
||||
int nbDirty = getNbDirtyBuffer(MAIN_VIEW) + getNbDirtyBuffer(SUB_VIEW);
|
||||
|
||||
if (!nbDirty)
|
||||
return false;
|
||||
|
||||
Buffer* curBuf = _pEditView->getCurrentBuffer();
|
||||
if (nbDirty == 1 && curBuf->isDirty())
|
||||
{
|
||||
fileSave(curBuf);
|
||||
}
|
||||
else if (fileSaveAllConfirm())
|
||||
{
|
||||
if (viewVisible(MAIN_VIEW))
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue