diff --git a/PowerEditor/src/NppIO.cpp b/PowerEditor/src/NppIO.cpp index b0f84b5b0..38479b3c9 100644 --- a/PowerEditor/src/NppIO.cpp +++ b/PowerEditor/src/NppIO.cpp @@ -1499,7 +1499,7 @@ bool Notepad_plus::fileSave(BufferID id) const NppGUI & nppgui = (NppParameters::getInstance()).getNppGUI(); BackupFeature backup = nppgui._backup; - if (backup != bak_none) + if (backup != bak_none && !buf->isLargeFile()) { const TCHAR *fn = buf->getFullPathName(); TCHAR *name = ::PathFindFileName(fn); diff --git a/PowerEditor/src/NppNotification.cpp b/PowerEditor/src/NppNotification.cpp index 01a78d648..275b2723d 100644 --- a/PowerEditor/src/NppNotification.cpp +++ b/PowerEditor/src/NppNotification.cpp @@ -660,11 +660,15 @@ BOOL Notepad_plus::notify(SCNotification *notification) if (indentMaintain) maintainIndentation(static_cast(notification->ch)); - AutoCompletion * autoC = isFromPrimary ? &_autoCompleteMain : &_autoCompleteSub; - bool isColumnMode = _pEditView->execute(SCI_GETSELECTIONS) > 1; // Multi-Selection || Column mode) - if (nppGui._matchedPairConf.hasAnyPairsPair() && !isColumnMode) - autoC->insertMatchedChars(notification->ch, nppGui._matchedPairConf); - autoC->update(notification->ch); + Buffer* currentBuf = _pEditView->getCurrentBuffer(); + if (!currentBuf->isLargeFile()) + { + AutoCompletion* autoC = isFromPrimary ? &_autoCompleteMain : &_autoCompleteSub; + bool isColumnMode = _pEditView->execute(SCI_GETSELECTIONS) > 1; // Multi-Selection || Column mode) + if (nppGui._matchedPairConf.hasAnyPairsPair() && !isColumnMode) + autoC->insertMatchedChars(notification->ch, nppGui._matchedPairConf); + autoC->update(notification->ch); + } } break; } diff --git a/PowerEditor/src/ScintillaComponent/Buffer.cpp b/PowerEditor/src/ScintillaComponent/Buffer.cpp index 9e4f86788..f9c04a89e 100644 --- a/PowerEditor/src/ScintillaComponent/Buffer.cpp +++ b/PowerEditor/src/ScintillaComponent/Buffer.cpp @@ -654,11 +654,26 @@ BufferID FileManager::loadFile(const TCHAR* filename, Document doc, int encoding int64_t 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 + // * the backups on save feature will be disabled for large files + bool isLargeFile = fileSize >= NPP_STYLING_FILESIZE_LIMIT; + + // Due to the performance issue, the Word Wrap feature will be disabled if it's ON + if (isLargeFile) + { + bool isWrap = _pNotepadPlus->_pEditView->isWrap(); + if (isWrap) + { + _pNotepadPlus->command(IDM_VIEW_WRAP); + } + } + bool ownDoc = false; if (!doc) { // If file exceeds 200MB, activate large file mode - doc = (Document)_pscratchTilla->execute(SCI_CREATEDOCUMENT, 0, fileSize < NPP_STYLING_FILESIZE_LIMIT ? 0 : SC_DOCUMENTOPTION_STYLES_NONE | SC_DOCUMENTOPTION_TEXT_LARGE); + doc = (Document)_pscratchTilla->execute(SCI_CREATEDOCUMENT, 0, isLargeFile ? SC_DOCUMENTOPTION_STYLES_NONE | SC_DOCUMENTOPTION_TEXT_LARGE : 0); ownDoc = true; } @@ -706,6 +721,8 @@ BufferID FileManager::loadFile(const TCHAR* filename, Document doc, int encoding if (res != 0) // res == 1 or res == -1 newBuf->_timeStamp = fileNameTimestamp; + newBuf->_isLargeFile = isLargeFile; + _buffers.push_back(newBuf); ++_nbBufs; Buffer* buf = _buffers.at(_nbBufs - 1); @@ -893,9 +910,12 @@ std::mutex backup_mutex; bool FileManager::backupCurrentBuffer() { + Buffer* buffer = _pNotepadPlus->getCurrentBuffer(); + if (buffer->isLargeFile()) + return false; + std::lock_guard lock(backup_mutex); - Buffer* buffer = _pNotepadPlus->getCurrentBuffer(); bool result = false; bool hasModifForSession = false; @@ -1387,18 +1407,13 @@ bool FileManager::loadFileData(Document doc, int64_t fileSize, const TCHAR * fil int res = pNativeSpeaker->messageBox("WantToOpenHugeFile", _pNotepadPlus->_pEditView->getHSelf(), - TEXT("Opening a huge file of 2GB+ could take several minutes.\nDo you want to open it?\n(Due to the performance issue, the Word Wrap feature will be disabled if it's ON)"), + TEXT("Opening a huge file of 2GB+ could take several minutes.\nDo you want to open it?"), TEXT("Opening huge file warning"), MB_YESNO | MB_APPLMODAL); if (res == IDYES) { - // Due to the performance issue, the Word Wrap feature will be disabled if it's ON - bool isWrap = _pNotepadPlus->_pEditView->isWrap(); - if (isWrap) - { - _pNotepadPlus->command(IDM_VIEW_WRAP); - } + // Do nothing } else { diff --git a/PowerEditor/src/ScintillaComponent/Buffer.h b/PowerEditor/src/ScintillaComponent/Buffer.h index 74c057b9f..4d80ac5f9 100644 --- a/PowerEditor/src/ScintillaComponent/Buffer.h +++ b/PowerEditor/src/ScintillaComponent/Buffer.h @@ -292,6 +292,8 @@ public: bool isUnsync() const { return _isUnsync; } void setUnsync(bool val) { _isUnsync = val; } + bool isLargeFile() const { return _isLargeFile; } + void startMonitoring() { _isMonitoringOn = true; _eventHandle = ::CreateEvent(nullptr, TRUE, FALSE, nullptr); @@ -344,6 +346,7 @@ private: bool _isUserReadOnly = false; bool _needLexer = false; // new buffers do not need lexing, Scintilla takes care of that //these properties have to be duplicated because of multiple references + //All the vectors must have the same size at all times std::vector _referees; // Instances of ScintillaEditView which contain this buffer std::vector _positions; @@ -372,6 +375,7 @@ private: // 2. the file is modified by another app but the buffer is not reloaded in Notepad++. // Note that if the buffer is untitled, there's no correspondent file on the disk so the buffer is considered as independent therefore synchronized. + bool _isLargeFile = false; // The loading of huge files will disable automatically 1. auto-completion 2. snapshot periode backup 3. backup on save 4. word wrap // For the monitoring HANDLE _eventHandle = nullptr;