diff --git a/PowerEditor/src/NppCommands.cpp b/PowerEditor/src/NppCommands.cpp index 04926798..43b201bc 100644 --- a/PowerEditor/src/NppCommands.cpp +++ b/PowerEditor/src/NppCommands.cpp @@ -2384,9 +2384,9 @@ void Notepad_plus::command(int id) case IDM_EDIT_LTR : { _pEditView->changeTextDirection(id == IDM_EDIT_RTL); - - // Wrap then !wrap to fix problem of mirror characters - bool isWraped = _pEditView->isWrap(); + + // Wrap then !wrap to fix problem of mirror characters + bool isWraped = _pEditView->isWrap(); _pEditView->wrap(!isWraped); _pEditView->wrap(isWraped); if (_pDocMap) diff --git a/PowerEditor/src/NppIO.cpp b/PowerEditor/src/NppIO.cpp index 47f5ea0b..148155a9 100644 --- a/PowerEditor/src/NppIO.cpp +++ b/PowerEditor/src/NppIO.cpp @@ -168,6 +168,8 @@ BufferID Notepad_plus::doOpen(const TCHAR *fileName, bool isRecursive, bool isRe scnN.nmhdr.idFrom = (uptr_t)buffer; scnN.nmhdr.code = NPPN_SNAPSHOTDIRTYFILELOADED; _pluginsManager.notify(&scnN); + + buffer->setLoadedDirty(true); } } } diff --git a/PowerEditor/src/NppNotification.cpp b/PowerEditor/src/NppNotification.cpp index 708dca1d..a91a87f4 100644 --- a/PowerEditor/src/NppNotification.cpp +++ b/PowerEditor/src/NppNotification.cpp @@ -94,20 +94,36 @@ BOOL Notepad_plus::notify(SCNotification *notification) { //Done by invisibleEditView? BufferID id = BUFFER_INVALID; - if (notification->nmhdr.hwndFrom == _invisibleEditView.getHSelf()) { + if (notification->nmhdr.hwndFrom == _invisibleEditView.getHSelf()) + { id = MainFileManager->getBufferFromDocument(_invisibleEditView.execute(SCI_GETDOCPOINTER)); - } else if (notification->nmhdr.hwndFrom == _fileEditView.getHSelf()) { + } + else if (notification->nmhdr.hwndFrom == _fileEditView.getHSelf()) + { id = MainFileManager->getBufferFromDocument(_fileEditView.execute(SCI_GETDOCPOINTER)); - } else { + } + else + { break; //wrong scintilla } - if (id != BUFFER_INVALID) { + + if (id != BUFFER_INVALID) + { buf = MainFileManager->getBufferByID(id); - } else { + } + else + { break; } } bool isDirty = notification->nmhdr.code == SCN_SAVEPOINTLEFT; + bool isSnapshotMode = NppParameters::getInstance()->getNppGUI().isSnapshotMode(); + if (isSnapshotMode && !isDirty) + { + bool canUndo = _pEditView->execute(SCI_CANUNDO) == TRUE; + if (!canUndo && buf->isLoadedDirty()) + isDirty = true; + } buf->setDirty(isDirty); break; } diff --git a/PowerEditor/src/ScitillaComponent/Buffer.cpp b/PowerEditor/src/ScitillaComponent/Buffer.cpp index 22c38952..579089c5 100644 --- a/PowerEditor/src/ScitillaComponent/Buffer.cpp +++ b/PowerEditor/src/ScitillaComponent/Buffer.cpp @@ -47,7 +47,7 @@ const int LF = 0x0A; Buffer::Buffer(FileManager * pManager, BufferID id, Document doc, DocFileStatus type, const TCHAR *fileName) //type must be either DOC_REGULAR or DOC_UNNAMED : _pManager(pManager), _id(id), _isDirty(false), _doc(doc), _isFileReadOnly(false), _isUserReadOnly(false), _recentTag(-1), _references(0), - _canNotify(false), _timeStamp(0), _needReloading(false), _encoding(-1), _backupFileName(TEXT("")), _isModified(false), _lang(L_TEXT) + _canNotify(false), _timeStamp(0), _needReloading(false), _encoding(-1), _backupFileName(TEXT("")), _isModified(false), _isLoadedDirty(false), _lang(L_TEXT) { NppParameters *pNppParamInst = NppParameters::getInstance(); const NewDocDefaultSettings & ndds = (pNppParamInst->getNppGUI()).getNewDocDefaultSettings(); diff --git a/PowerEditor/src/ScitillaComponent/Buffer.h b/PowerEditor/src/ScitillaComponent/Buffer.h index b6ee3c76..51c30cba 100644 --- a/PowerEditor/src/ScitillaComponent/Buffer.h +++ b/PowerEditor/src/ScitillaComponent/Buffer.h @@ -322,6 +322,13 @@ public : generic_string getBackupFileName() const {return _backupFileName;}; void setBackupFileName(generic_string fileName) {_backupFileName = fileName;}; time_t getLastModifiedTimestamp() const {return _timeStamp;}; + bool isLoadedDirty() const { + return _isLoadedDirty; + }; + + void setLoadedDirty(bool val) { + _isLoadedDirty = val; + }; private : FileManager * _pManager; @@ -350,7 +357,7 @@ private : //Environment properties DocFileStatus _currentStatus; time_t _timeStamp; // 0 if it's a new doc - //time_t _backupModifiedTimeStamp; // 0 if backup file is not created + bool _isFileReadOnly; generic_string _fullPathName; TCHAR * _fileName; //points to filename part in _fullPathName @@ -362,6 +369,7 @@ private : // For backup system generic_string _backupFileName; // default: "" bool _isModified; // default: false + bool _isLoadedDirty; // default: false void updateTimeStamp();