From ed40f1151579100874de703f5a8541aa7c73c2bc Mon Sep 17 00:00:00 2001 From: Don Ho Date: Mon, 10 Jan 2022 05:08:15 +0100 Subject: [PATCH] Fix loaded session being empty on exit In the following configuration loaded session will be empty on exit * Remember current session for next launch: OFF * Open session in a new instance: ON This commit fix the issue. Fix #10986, close #11017 --- PowerEditor/src/Notepad_plus.cpp | 2 +- PowerEditor/src/NppBigSwitch.cpp | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/PowerEditor/src/Notepad_plus.cpp b/PowerEditor/src/Notepad_plus.cpp index ff17dd540..82a4eaa20 100644 --- a/PowerEditor/src/Notepad_plus.cpp +++ b/PowerEditor/src/Notepad_plus.cpp @@ -5703,7 +5703,7 @@ void Notepad_plus::getCurrentOpenedFiles(Session & session, bool includUntitledD for (size_t i = 0, len = docTab[k]->nbItem(); i < len ; ++i) { BufferID bufID = docTab[k]->getBufferByIndex(i); - ScintillaEditView *editView = k == 0?&_mainEditView:&_subEditView; + ScintillaEditView *editView = k == 0 ? &_mainEditView : &_subEditView; size_t activeIndex = k == 0 ? session._activeMainIndex : session._activeSubIndex; vector *viewFiles = (vector *)(k == 0?&(session._mainViewFiles):&(session._subViewFiles)); diff --git a/PowerEditor/src/NppBigSwitch.cpp b/PowerEditor/src/NppBigSwitch.cpp index 76902dd7c..1f1756cc4 100644 --- a/PowerEditor/src/NppBigSwitch.cpp +++ b/PowerEditor/src/NppBigSwitch.cpp @@ -1964,9 +1964,10 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT message, WPARAM wParam, LPARAM lPa } Session currentSession; + getCurrentOpenedFiles(currentSession, true); + if (nppgui._rememberLastSession) { - getCurrentOpenedFiles(currentSession, true); //Lock the recent file list so it isnt populated with opened files //Causing them to show on restart even though they are loaded by session _lastRecentFileList.setLock(true); //only lock when the session is remembered @@ -2032,7 +2033,6 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT message, WPARAM wParam, LPARAM lPa // // saving session.xml into loaded session if a saved session is loaded and saveLoadedSessionOnExit option is enabled // - generic_string loadedSessionFilePath = nppParam.getLoadedSessionFilePath(); if (!loadedSessionFilePath.empty() && PathFileExists(loadedSessionFilePath.c_str())) nppParam.writeSession(currentSession, loadedSessionFilePath.c_str());