[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
This commit is contained in:
Don Ho 2013-07-27 17:30:55 +00:00
parent e89c5b9dfb
commit bc17d47825

View File

@ -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