[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:
parent
428df19cbc
commit
d2651832ea
@ -2384,9 +2384,9 @@ void Notepad_plus::command(int id)
|
|||||||
case IDM_EDIT_LTR :
|
case IDM_EDIT_LTR :
|
||||||
{
|
{
|
||||||
_pEditView->changeTextDirection(id == IDM_EDIT_RTL);
|
_pEditView->changeTextDirection(id == IDM_EDIT_RTL);
|
||||||
|
|
||||||
// Wrap then !wrap to fix problem of mirror characters
|
// Wrap then !wrap to fix problem of mirror characters
|
||||||
bool isWraped = _pEditView->isWrap();
|
bool isWraped = _pEditView->isWrap();
|
||||||
_pEditView->wrap(!isWraped);
|
_pEditView->wrap(!isWraped);
|
||||||
_pEditView->wrap(isWraped);
|
_pEditView->wrap(isWraped);
|
||||||
if (_pDocMap)
|
if (_pDocMap)
|
||||||
|
@ -168,6 +168,8 @@ BufferID Notepad_plus::doOpen(const TCHAR *fileName, bool isRecursive, bool isRe
|
|||||||
scnN.nmhdr.idFrom = (uptr_t)buffer;
|
scnN.nmhdr.idFrom = (uptr_t)buffer;
|
||||||
scnN.nmhdr.code = NPPN_SNAPSHOTDIRTYFILELOADED;
|
scnN.nmhdr.code = NPPN_SNAPSHOTDIRTYFILELOADED;
|
||||||
_pluginsManager.notify(&scnN);
|
_pluginsManager.notify(&scnN);
|
||||||
|
|
||||||
|
buffer->setLoadedDirty(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -94,20 +94,36 @@ BOOL Notepad_plus::notify(SCNotification *notification)
|
|||||||
{
|
{
|
||||||
//Done by invisibleEditView?
|
//Done by invisibleEditView?
|
||||||
BufferID id = BUFFER_INVALID;
|
BufferID id = BUFFER_INVALID;
|
||||||
if (notification->nmhdr.hwndFrom == _invisibleEditView.getHSelf()) {
|
if (notification->nmhdr.hwndFrom == _invisibleEditView.getHSelf())
|
||||||
|
{
|
||||||
id = MainFileManager->getBufferFromDocument(_invisibleEditView.execute(SCI_GETDOCPOINTER));
|
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));
|
id = MainFileManager->getBufferFromDocument(_fileEditView.execute(SCI_GETDOCPOINTER));
|
||||||
} else {
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
break; //wrong scintilla
|
break; //wrong scintilla
|
||||||
}
|
}
|
||||||
if (id != BUFFER_INVALID) {
|
|
||||||
|
if (id != BUFFER_INVALID)
|
||||||
|
{
|
||||||
buf = MainFileManager->getBufferByID(id);
|
buf = MainFileManager->getBufferByID(id);
|
||||||
} else {
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
bool isDirty = notification->nmhdr.code == SCN_SAVEPOINTLEFT;
|
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);
|
buf->setDirty(isDirty);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -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
|
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),
|
: _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();
|
NppParameters *pNppParamInst = NppParameters::getInstance();
|
||||||
const NewDocDefaultSettings & ndds = (pNppParamInst->getNppGUI()).getNewDocDefaultSettings();
|
const NewDocDefaultSettings & ndds = (pNppParamInst->getNppGUI()).getNewDocDefaultSettings();
|
||||||
|
@ -322,6 +322,13 @@ public :
|
|||||||
generic_string getBackupFileName() const {return _backupFileName;};
|
generic_string getBackupFileName() const {return _backupFileName;};
|
||||||
void setBackupFileName(generic_string fileName) {_backupFileName = fileName;};
|
void setBackupFileName(generic_string fileName) {_backupFileName = fileName;};
|
||||||
time_t getLastModifiedTimestamp() const {return _timeStamp;};
|
time_t getLastModifiedTimestamp() const {return _timeStamp;};
|
||||||
|
bool isLoadedDirty() const {
|
||||||
|
return _isLoadedDirty;
|
||||||
|
};
|
||||||
|
|
||||||
|
void setLoadedDirty(bool val) {
|
||||||
|
_isLoadedDirty = val;
|
||||||
|
};
|
||||||
|
|
||||||
private :
|
private :
|
||||||
FileManager * _pManager;
|
FileManager * _pManager;
|
||||||
@ -350,7 +357,7 @@ private :
|
|||||||
//Environment properties
|
//Environment properties
|
||||||
DocFileStatus _currentStatus;
|
DocFileStatus _currentStatus;
|
||||||
time_t _timeStamp; // 0 if it's a new doc
|
time_t _timeStamp; // 0 if it's a new doc
|
||||||
//time_t _backupModifiedTimeStamp; // 0 if backup file is not created
|
|
||||||
bool _isFileReadOnly;
|
bool _isFileReadOnly;
|
||||||
generic_string _fullPathName;
|
generic_string _fullPathName;
|
||||||
TCHAR * _fileName; //points to filename part in _fullPathName
|
TCHAR * _fileName; //points to filename part in _fullPathName
|
||||||
@ -362,6 +369,7 @@ private :
|
|||||||
// For backup system
|
// For backup system
|
||||||
generic_string _backupFileName; // default: ""
|
generic_string _backupFileName; // default: ""
|
||||||
bool _isModified; // default: false
|
bool _isModified; // default: false
|
||||||
|
bool _isLoadedDirty; // default: false
|
||||||
|
|
||||||
void updateTimeStamp();
|
void updateTimeStamp();
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user