From 2132505cba1895468231f582942aa9a292563b77 Mon Sep 17 00:00:00 2001 From: Don Ho Date: Wed, 26 Jan 2022 17:49:37 +0100 Subject: [PATCH] Fix unsaved untitled files not being opened on the next session regression Fix #11080 --- PowerEditor/src/ScintillaComponent/Buffer.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/PowerEditor/src/ScintillaComponent/Buffer.cpp b/PowerEditor/src/ScintillaComponent/Buffer.cpp index 8028c06c5..39d03ab3d 100644 --- a/PowerEditor/src/ScintillaComponent/Buffer.cpp +++ b/PowerEditor/src/ScintillaComponent/Buffer.cpp @@ -640,12 +640,16 @@ void FileManager::closeBuffer(BufferID id, ScintillaEditView * identifier) // backupFileName is sentinel of backup mode: if it's not NULL, then we use it (load it). Otherwise we use filename -BufferID FileManager::loadFile(const TCHAR * filename, Document doc, int encoding, const TCHAR *backupFileName, FILETIME fileNameTimestamp) +BufferID FileManager::loadFile(const TCHAR* filename, Document doc, int encoding, const TCHAR* backupFileName, FILETIME fileNameTimestamp) { //Get file size - FILE* fp = generic_fopen(filename, TEXT("rb")); + const TCHAR* pPath = filename; + if (!::PathFileExists(pPath)) + pPath = backupFileName; + FILE* fp = generic_fopen(pPath, TEXT("rb")); if (!fp) return BUFFER_INVALID; + _fseeki64(fp, 0, SEEK_END); int64_t fileSize = _ftelli64(fp); fclose(fp);