From b694ff23bb47eff860a37a5c92c19c972070bca0 Mon Sep 17 00:00:00 2001 From: Rajendra Singh Date: Wed, 13 Nov 2019 07:45:54 +0530 Subject: [PATCH] Fix issue of showing save dialog twice The issue: While running "close all" command the 2nd save dialog is shown for a unsaved cloned doc, but user has repplyed "No" to the unsaved original doc. This comit make save dialog show once if user's answer is No. Fix #7523, close #7558 --- PowerEditor/src/NppIO.cpp | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/PowerEditor/src/NppIO.cpp b/PowerEditor/src/NppIO.cpp index c29e9633b..1ec7176e3 100644 --- a/PowerEditor/src/NppIO.cpp +++ b/PowerEditor/src/NppIO.cpp @@ -36,6 +36,7 @@ #include "functionListPanel.h" #include "ReadDirectoryChanges.h" #include +#include using namespace std; @@ -899,10 +900,18 @@ bool Notepad_plus::fileCloseAll(bool doDeleteBackup, bool isSnapshotMode) //closes all documents, makes the current view the only one visible //first check if we need to save any file + //check in the both view + std::unordered_set uniqueBuffers; + for (size_t i = 0; i < _mainDocTab.nbItem() && !noSaveToAll; ++i) { BufferID id = _mainDocTab.getBufferByIndex(i); Buffer * buf = MainFileManager.getBufferByID(id); + + // Put all the BufferID from main vaiew to hash table + // hash table is used for fast searching + uniqueBuffers.insert(id); + if (buf->isUntitled() && buf->docLength() == 0) { // Do nothing @@ -981,6 +990,11 @@ bool Notepad_plus::fileCloseAll(bool doDeleteBackup, bool isSnapshotMode) { BufferID id = _subDocTab.getBufferByIndex(i); Buffer * buf = MainFileManager.getBufferByID(id); + + // Is this buffer already included? + if (uniqueBuffers.find(id) != uniqueBuffers.end()) + continue; + if (buf->isUntitled() && buf->docLength() == 0) { // Do nothing