From 1f1ce89572bfa890ecde8ea7eb2a3af81c073c8b Mon Sep 17 00:00:00 2001 From: Don Ho Date: Tue, 19 Jan 2010 23:30:16 +0000 Subject: [PATCH] [BUG_FIXED] (Author : Beetny) Fix "Close Window(s)" in Window dialog bug (if file is dirty and cancel to close). git-svn-id: svn://svn.tuxfamily.org/svnroot/notepadplus/repository/trunk@600 f5eea248-9336-0410-98b8-ebc06183d4e3 --- PowerEditor/src/Notepad_plus.cpp | 26 +++++++++++++++++++------- 1 file changed, 19 insertions(+), 7 deletions(-) diff --git a/PowerEditor/src/Notepad_plus.cpp b/PowerEditor/src/Notepad_plus.cpp index 4aa66861..8b50f44a 100644 --- a/PowerEditor/src/Notepad_plus.cpp +++ b/PowerEditor/src/Notepad_plus.cpp @@ -10178,15 +10178,27 @@ LRESULT Notepad_plus::runProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPa break; case WDT_CLOSE: { + bool closed; + //loop through nmdlg->nItems, get index and close it - for (int i = 0; i < (int)nmdlg->nItems; i++) { - fileClose(_pDocTab->getBufferByIndex(nmdlg->Items[i]), currentView()); + for (int i = 0; i < (int)nmdlg->nItems; i++) + { + closed = fileClose(_pDocTab->getBufferByIndex(nmdlg->Items[i]), currentView()); UINT pos = nmdlg->Items[i]; - nmdlg->Items[i] = 0xFFFFFFFF; // indicate file was closed - - for (int j=i+1; j<(int)nmdlg->nItems; ++j) - if (nmdlg->Items[j] > pos) - --nmdlg->Items[j]; + // The window list only needs to be rearranged when the file was actually closed + if (closed) + { + nmdlg->Items[i] = 0xFFFFFFFF; // indicate file was closed + + // Shift the remaining items downward to fill the gap + for (int j = i + 1; j < (int)nmdlg->nItems; j++) + { + if (nmdlg->Items[j] > pos) + { + nmdlg->Items[j]--; + } + } + } } nmdlg->processed = TRUE; }