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
This commit is contained in:
Don Ho 2022-01-10 05:08:15 +01:00
parent e40aec0b3f
commit ed40f11515
2 changed files with 3 additions and 3 deletions

View File

@ -1964,9 +1964,10 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT message, WPARAM wParam, LPARAM lPa
} }
Session currentSession; Session currentSession;
getCurrentOpenedFiles(currentSession, true);
if (nppgui._rememberLastSession) if (nppgui._rememberLastSession)
{ {
getCurrentOpenedFiles(currentSession, true);
//Lock the recent file list so it isnt populated with opened files //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 //Causing them to show on restart even though they are loaded by session
_lastRecentFileList.setLock(true); //only lock when the session is remembered _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 // saving session.xml into loaded session if a saved session is loaded and saveLoadedSessionOnExit option is enabled
// //
generic_string loadedSessionFilePath = nppParam.getLoadedSessionFilePath(); generic_string loadedSessionFilePath = nppParam.getLoadedSessionFilePath();
if (!loadedSessionFilePath.empty() && PathFileExists(loadedSessionFilePath.c_str())) if (!loadedSessionFilePath.empty() && PathFileExists(loadedSessionFilePath.c_str()))
nppParam.writeSession(currentSession, loadedSessionFilePath.c_str()); nppParam.writeSession(currentSession, loadedSessionFilePath.c_str());