[BUG_FIXED] Fix undo actions on unsaved snapshot file removing the dirty state bug.

git-svn-id: svn://svn.tuxfamily.org/svnroot/notepadplus/repository/trunk@1304 f5eea248-9336-0410-98b8-ebc06183d4e3
This commit is contained in:
Don Ho 2014-12-09 23:16:48 +00:00
parent 428df19cbc
commit d2651832ea
5 changed files with 36 additions and 10 deletions

View File

@ -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);
}
}
}

View File

@ -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;
}

View File

@ -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();

View File

@ -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();