diff --git a/PowerEditor/src/NppIO.cpp b/PowerEditor/src/NppIO.cpp index af8361828..b46f3c99e 100644 --- a/PowerEditor/src/NppIO.cpp +++ b/PowerEditor/src/NppIO.cpp @@ -2145,7 +2145,7 @@ bool Notepad_plus::loadSession(Session & session, bool isSnapshotMode, bool shou } else { - lastOpened = BUFFER_INVALID; + lastOpened = MainFileManager.newPlaceholderDocument(pFn, MAIN_VIEW); } if (isWow64Off) { @@ -2283,7 +2283,7 @@ bool Notepad_plus::loadSession(Session & session, bool isSnapshotMode, bool shou } else { - lastOpened = BUFFER_INVALID; + lastOpened = MainFileManager.newPlaceholderDocument(pFn, SUB_VIEW); } if (isWow64Off) { diff --git a/PowerEditor/src/ScintillaComponent/Buffer.cpp b/PowerEditor/src/ScintillaComponent/Buffer.cpp index 703c82067..4ca5ca0c3 100644 --- a/PowerEditor/src/ScintillaComponent/Buffer.cpp +++ b/PowerEditor/src/ScintillaComponent/Buffer.cpp @@ -1347,6 +1347,15 @@ BufferID FileManager::newEmptyDocument() return id; } +BufferID FileManager::newPlaceholderDocument(const TCHAR* missingFilename, int whichOne) +{ + BufferID buf = MainFileManager.newEmptyDocument(); + _pNotepadPlus->loadBufferIntoView(buf, whichOne); + buf->setFileName(missingFilename); + buf->_currentStatus = DOC_REGULAR; + return buf; +} + BufferID FileManager::bufferFromDocument(Document doc, bool isMainEditZone) { NppParameters& nppParamInst = NppParameters::getInstance(); diff --git a/PowerEditor/src/ScintillaComponent/Buffer.h b/PowerEditor/src/ScintillaComponent/Buffer.h index 697094a1c..29ab6b384 100644 --- a/PowerEditor/src/ScintillaComponent/Buffer.h +++ b/PowerEditor/src/ScintillaComponent/Buffer.h @@ -88,6 +88,8 @@ public: BufferID loadFile(const TCHAR * filename, Document doc = static_cast(NULL), int encoding = -1, const TCHAR *backupFileName = nullptr, FILETIME fileNameTimestamp = {}); //ID == BUFFER_INVALID on failure. If Doc == NULL, a new file is created, otherwise data is loaded in given document BufferID newEmptyDocument(); + // create an empty placeholder for a missing file when loading session + BufferID newPlaceholderDocument(const TCHAR * missingFilename, int whichOne); //create Buffer from existing Scintilla, used from new Scintillas. BufferID bufferFromDocument(Document doc, bool isMainEditZone);