diff --git a/PowerEditor/src/ScintillaComponent/Buffer.cpp b/PowerEditor/src/ScintillaComponent/Buffer.cpp index f9c04a89e..a6da5caa8 100644 --- a/PowerEditor/src/ScintillaComponent/Buffer.cpp +++ b/PowerEditor/src/ScintillaComponent/Buffer.cpp @@ -643,16 +643,22 @@ void FileManager::closeBuffer(BufferID id, ScintillaEditView * identifier) BufferID FileManager::loadFile(const TCHAR* filename, Document doc, int encoding, const TCHAR* backupFileName, FILETIME fileNameTimestamp) { //Get file size + int64_t fileSize = -1; 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); + } + if (pPath) + { + FILE* fp = generic_fopen(pPath, TEXT("rb")); + if (fp) + { + _fseeki64(fp, 0, SEEK_END); + fileSize = _ftelli64(fp); + fclose(fp); + } + } // * the auto-completion feature will be disabled for large files // * the session snapshotsand periodic backups feature will be disabled for large files diff --git a/scintilla/include/Sci_Position.h b/scintilla/include/Sci_Position.h index b979bd0be..bad91b449 100644 --- a/scintilla/include/Sci_Position.h +++ b/scintilla/include/Sci_Position.h @@ -20,7 +20,7 @@ typedef size_t Sci_PositionU; // For Sci_CharacterRange which is defined as long to be compatible with Win32 CHARRANGE -typedef long Sci_PositionCR; +typedef intptr_t Sci_PositionCR; #ifdef _WIN32 #define SCI_METHOD __stdcall