Improve 'Close all to the left' and 'Close all to the right' user experience

Description of the Issue
Improve "Close all to the left/right" functionality.
This is an enhancement request. Similar request was made in past #2555, but has been closed during tracker cleanup process.

Steps to Reproduce the Issue
1. Create 4 tabs says (tab 1, tab 2, tab 3, tab 4)
2. Make all the tab dirty (I mean type, something in each tab, but don't save any).
3. Now right click on tab 1 and choose "Close All to the right"
4. Three popup for asking to save file will appear (For tab 4, tab 3 and tab 2)
5. Click "No" for tab 4 and tab 3. And click cancel for tab 2.

Expected Behavior:
After step 5, tab 4 and tab 3 should be closed. And for Remaining tabs, operation should be cancelled.

Actual Behavior:
Nothing happens after step 5.

Same defect reproduction steps are applicable for "Close all to the left".

Fix #7501, close #7502
pull/7554/head
Rajendra Singh 5 years ago committed by Don HO
parent 485b5aa7c7
commit 4d5c1b6564
No known key found for this signature in database
GPG Key ID: 6C429F1D8D84F46E

@ -1074,22 +1074,23 @@ bool Notepad_plus::fileCloseAll(bool doDeleteBackup, bool isSnapshotMode)
return true;
}
bool Notepad_plus::fileCloseAllGiven(const std::vector<int> &krvecBufferIndexes)
bool Notepad_plus::fileCloseAllGiven(const std::vector<int>& krvecBufferIndexes)
{
// First check if we need to save any file.
std::vector<int>::const_iterator itIndexesEnd = krvecBufferIndexes.end();
bool noSaveToAll = false;
bool saveToAll = false;
std::vector<int> bufferIndexesToClose;
for (std::vector<int>::const_iterator itIndex = krvecBufferIndexes.begin(); itIndex != itIndexesEnd; ++itIndex)
for (const auto& index : krvecBufferIndexes)
{
BufferID id = _pDocTab->getBufferByIndex(*itIndex);
Buffer * buf = MainFileManager.getBufferByID(id);
if (buf->isUntitled() && buf->docLength() == 0)
BufferID id = _pDocTab->getBufferByIndex(index);
Buffer* buf = MainFileManager.getBufferByID(id);
if ((buf->isUntitled() && buf->docLength() == 0) || noSaveToAll || !buf->isDirty())
{
// Do nothing.
// Do nothing, these documents are already ready to close
bufferIndexesToClose.push_back(index);
}
else if (buf->isDirty() && !noSaveToAll)
{
@ -1105,44 +1106,44 @@ bool Notepad_plus::fileCloseAllGiven(const std::vector<int> &krvecBufferIndexes)
switchEditViewTo(SUB_VIEW);
}
int res = -1;
if (saveToAll)
{
res = IDYES;
}
else
{
res = doSaveOrNot(buf->getFullPathName(), true);
}
/* Do you want to save
* IDYES : Yes
* IDRETRY : Yes to All
* IDNO : No
* IDIGNORE : No To All
* IDCANCEL : Cancel Opration
*/
int res = saveToAll ? IDYES : doSaveOrNot(buf->getFullPathName(), true);
if (res == IDYES)
if (res == IDYES || res == IDRETRY)
{
if (!fileSave(id))
return false; // Abort entire procedure.
}
else if (res == IDCANCEL)
{
return false;
break; // Abort entire procedure, but close whatever processed so far
bufferIndexesToClose.push_back(index);
if (res == IDRETRY)
saveToAll = true;
}
else if (res == IDIGNORE)
else if (res == IDNO || res == IDIGNORE)
{
noSaveToAll = true;
bufferIndexesToClose.push_back(index);
if (res == IDIGNORE)
noSaveToAll = true;
}
else if (res == IDRETRY)
else if (res == IDCANCEL)
{
if (!fileSave(id))
return false; // Abort entire procedure.
saveToAll = true;
break;
}
}
}
// Now we close.
bool isSnapshotMode = NppParameters::getInstance().getNppGUI().isSnapshotMode();
for (std::vector<int>::const_iterator itIndex = krvecBufferIndexes.begin(); itIndex != itIndexesEnd; ++itIndex)
for (const auto& index : bufferIndexesToClose)
{
doClose(_pDocTab->getBufferByIndex(*itIndex), currentView(), isSnapshotMode);
doClose(_pDocTab->getBufferByIndex(index), currentView(), isSnapshotMode);
}
return true;

Loading…
Cancel
Save