Allow undo after file reload and don't purge undo buffer
Close #5273, fix #5141
This commit is contained in:
parent
017e09a23d
commit
198cf90c16
|
@ -674,7 +674,7 @@ bool FileManager::reloadBuffer(BufferID id)
|
||||||
buf->setLoadedDirty(false); // Since the buffer will be reloaded from the disk, and it will be clean (not dirty), we can set _isLoadedDirty false safetly.
|
buf->setLoadedDirty(false); // Since the buffer will be reloaded from the disk, and it will be clean (not dirty), we can set _isLoadedDirty false safetly.
|
||||||
// Set _isLoadedDirty false before calling "_pscratchTilla->execute(SCI_CLEARALL);" in loadFileData() to avoid setDirty in SCN_SAVEPOINTREACHED / SCN_SAVEPOINTLEFT
|
// Set _isLoadedDirty false before calling "_pscratchTilla->execute(SCI_CLEARALL);" in loadFileData() to avoid setDirty in SCN_SAVEPOINTREACHED / SCN_SAVEPOINTLEFT
|
||||||
|
|
||||||
bool res = loadFileData(doc, buf->getFullPathName(), data, &UnicodeConvertor, loadedFileFormat);
|
bool res = loadFileData(doc, buf->getFullPathName(), data, &UnicodeConvertor, loadedFileFormat, false);
|
||||||
buf->_canNotify = true;
|
buf->_canNotify = true;
|
||||||
|
|
||||||
if (res)
|
if (res)
|
||||||
|
@ -1261,7 +1261,7 @@ LangType FileManager::detectLanguageFromTextBegining(const unsigned char *data,
|
||||||
return L_TEXT;
|
return L_TEXT;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool FileManager::loadFileData(Document doc, const TCHAR * filename, char* data, Utf8_16_Read * unicodeConvertor, LoadedFileFormat& fileFormat)
|
bool FileManager::loadFileData(Document doc, const TCHAR * filename, char* data, Utf8_16_Read * unicodeConvertor, LoadedFileFormat& fileFormat, bool purgeUndoBuffer)
|
||||||
{
|
{
|
||||||
FILE *fp = generic_fopen(filename, TEXT("rb"));
|
FILE *fp = generic_fopen(filename, TEXT("rb"));
|
||||||
if (not fp)
|
if (not fp)
|
||||||
|
@ -1295,6 +1295,12 @@ bool FileManager::loadFileData(Document doc, const TCHAR * filename, char* data,
|
||||||
{
|
{
|
||||||
_pscratchTilla->execute(SCI_SETREADONLY, false);
|
_pscratchTilla->execute(SCI_SETREADONLY, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!purgeUndoBuffer)
|
||||||
|
{
|
||||||
|
_pscratchTilla->execute(SCI_BEGINUNDOACTION);
|
||||||
|
}
|
||||||
|
|
||||||
_pscratchTilla->execute(SCI_CLEARALL);
|
_pscratchTilla->execute(SCI_CLEARALL);
|
||||||
|
|
||||||
|
|
||||||
|
@ -1427,7 +1433,7 @@ bool FileManager::loadFileData(Document doc, const TCHAR * filename, char* data,
|
||||||
fileFormat._eolFormat = format;
|
fileFormat._eolFormat = format;
|
||||||
}
|
}
|
||||||
|
|
||||||
_pscratchTilla->execute(SCI_EMPTYUNDOBUFFER);
|
_pscratchTilla->execute(purgeUndoBuffer ? SCI_EMPTYUNDOBUFFER : SCI_ENDUNDOACTION);
|
||||||
_pscratchTilla->execute(SCI_SETSAVEPOINT);
|
_pscratchTilla->execute(SCI_SETSAVEPOINT);
|
||||||
|
|
||||||
if (ro)
|
if (ro)
|
||||||
|
|
|
@ -122,7 +122,7 @@ private:
|
||||||
};
|
};
|
||||||
~FileManager();
|
~FileManager();
|
||||||
int detectCodepage(char* buf, size_t len);
|
int detectCodepage(char* buf, size_t len);
|
||||||
bool loadFileData(Document doc, const TCHAR* filename, char* buffer, Utf8_16_Read* UnicodeConvertor, LoadedFileFormat& fileFormat);
|
bool loadFileData(Document doc, const TCHAR* filename, char* buffer, Utf8_16_Read* UnicodeConvertor, LoadedFileFormat& fileFormat, bool purgeUndoBuffer = true);
|
||||||
LangType detectLanguageFromTextBegining(const unsigned char *data, size_t dataLen);
|
LangType detectLanguageFromTextBegining(const unsigned char *data, size_t dataLen);
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue