From bc17d47825a977b3930f385c80705a6617d7971a Mon Sep 17 00:00:00 2001 From: Don Ho Date: Sat, 27 Jul 2013 17:30:55 +0000 Subject: [PATCH] [BUG_FIXED] Fix open session on another instance while session to open path contain space. [ENHANCEMENT] open session always on the same instance if no files opened in this instance. git-svn-id: svn://svn.tuxfamily.org/svnroot/notepadplus/repository/trunk@1087 f5eea248-9336-0410-98b8-ebc06183d4e3 --- PowerEditor/src/NppIO.cpp | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/PowerEditor/src/NppIO.cpp b/PowerEditor/src/NppIO.cpp index be0f096b..1b1ab2bc 100644 --- a/PowerEditor/src/NppIO.cpp +++ b/PowerEditor/src/NppIO.cpp @@ -1228,16 +1228,28 @@ bool Notepad_plus::fileLoadSession(const TCHAR *fn) sessionFileName = fn; } + NppParameters *pNppParam = NppParameters::getInstance(); const NppGUI & nppGUI = pNppParam->getNppGUI(); if (sessionFileName) { - if ((nppGUI._multiInstSetting == multiInstOnSession || nppGUI._multiInstSetting == multiInst)) + bool isEmptyNpp = false; + if (_mainDocTab.nbItem() == 1 && _subDocTab.nbItem() == 1) + { + Buffer * buf1 = MainFileManager->getBufferByID(_mainDocTab.getBufferByIndex(0)); + Buffer * buf2 = MainFileManager->getBufferByID(_subDocTab.getBufferByIndex(0)); + isEmptyNpp = (!buf1->isDirty() && buf1->isUntitled() && !buf2->isDirty() && buf2->isUntitled()); + } + if (!isEmptyNpp && (nppGUI._multiInstSetting == multiInstOnSession || nppGUI._multiInstSetting == multiInst)) { TCHAR nppFullPath[MAX_PATH]; ::GetModuleFileName(NULL, nppFullPath, MAX_PATH); + + generic_string args = TEXT("-multiInst -nosession -openSession "); + args += TEXT("\""); args += sessionFileName; + args += TEXT("\""); ::ShellExecute(_pPublicInterface->getHSelf(), TEXT("open"), nppFullPath, args.c_str(), TEXT("."), SW_SHOW); } else