diff --git a/PowerEditor/src/Notepad_plus.cpp b/PowerEditor/src/Notepad_plus.cpp index def15a60..7ff366f0 100644 --- a/PowerEditor/src/Notepad_plus.cpp +++ b/PowerEditor/src/Notepad_plus.cpp @@ -4989,7 +4989,9 @@ void Notepad_plus::getCurrentOpenedFiles(Session & session, bool includUntitledD generic_string languageName = getLangFromMenu(buf); const TCHAR *langName = languageName.c_str(); - sessionFileInfo sfi(buf->getFullPathName(), langName, buf->getEncoding(), buf->getPosition(editView), buf->getBackupFileName().c_str(), buf->getLastModifiedTimestamp(), buf->getMapPosition()); + sessionFileInfo sfi(buf->getFullPathName(), langName, buf->getEncoding(), buf->getUserReadOnly(), buf->getPosition(editView), buf->getBackupFileName().c_str(), buf->getLastModifiedTimestamp(), buf->getMapPosition()); + + sfi._isMonitoring = buf->isMonitoringOn(); _invisibleEditView.execute(SCI_SETDOCPOINTER, 0, buf->getDocument()); size_t maxLine = static_cast(_invisibleEditView.execute(SCI_GETLINECOUNT)); diff --git a/PowerEditor/src/NppIO.cpp b/PowerEditor/src/NppIO.cpp index b6f695d5..6f18b830 100644 --- a/PowerEditor/src/NppIO.cpp +++ b/PowerEditor/src/NppIO.cpp @@ -1718,6 +1718,8 @@ bool Notepad_plus::loadSession(Session & session, bool isSnapshotMode) if (session._mainViewFiles[i]._encoding != -1) buf->setEncoding(session._mainViewFiles[i]._encoding); + buf->setUserReadOnly(session._mainViewFiles[i]._isUserReadOnly); + if (isSnapshotMode && session._mainViewFiles[i]._backupFilePath != TEXT("") && PathFileExists(session._mainViewFiles[i]._backupFilePath.c_str())) buf->setDirty(true); @@ -1831,6 +1833,7 @@ bool Notepad_plus::loadSession(Session & session, bool isSnapshotMode) } buf->setLangType(typeToSet, pLn); buf->setEncoding(session._subViewFiles[k]._encoding); + buf->setUserReadOnly(session._mainViewFiles[k]._isUserReadOnly); if (isSnapshotMode && session._subViewFiles[k]._backupFilePath != TEXT("") && PathFileExists(session._subViewFiles[k]._backupFilePath.c_str())) buf->setDirty(true); diff --git a/PowerEditor/src/Parameters.cpp b/PowerEditor/src/Parameters.cpp index 8eef120b..99abc115 100644 --- a/PowerEditor/src/Parameters.cpp +++ b/PowerEditor/src/Parameters.cpp @@ -2122,7 +2122,12 @@ bool NppParameters::getSessionFromXmlTree(TiXmlDocument *pSessionDoc, Session *p (childNode->ToElement())->Attribute(TEXT("originalFileLastModifTimestamp"), reinterpret_cast(&fileModifiedTimestamp.dwLowDateTime)); (childNode->ToElement())->Attribute(TEXT("originalFileLastModifTimestampHigh"), reinterpret_cast(&fileModifiedTimestamp.dwHighDateTime)); - sessionFileInfo sfi(fileName, langName, encStr?encoding:-1, position, backupFilePath, fileModifiedTimestamp, mapPosition); + bool isUserReadOnly = false; + const TCHAR *boolStrReadOnly = (childNode->ToElement())->Attribute(TEXT("userReadOnly")); + if (boolStrReadOnly) + isUserReadOnly = _wcsicmp(TEXT("yes"), boolStrReadOnly) == 0; + + sessionFileInfo sfi(fileName, langName, encStr ? encoding : -1, isUserReadOnly, position, backupFilePath, fileModifiedTimestamp, mapPosition); for (TiXmlNode *markNode = childNode->FirstChildElement(TEXT("Mark")); markNode ; @@ -3137,6 +3142,7 @@ void NppParameters::writeSession(const Session & session, const TCHAR *fileName) (fileNameNode->ToElement())->SetAttribute(TEXT("selMode"), viewSessionFiles[i]._selMode); (fileNameNode->ToElement())->SetAttribute(TEXT("lang"), viewSessionFiles[i]._langName.c_str()); (fileNameNode->ToElement())->SetAttribute(TEXT("encoding"), viewSessionFiles[i]._encoding); + (fileNameNode->ToElement())->SetAttribute(TEXT("userReadOnly"), (viewSessionFiles[i]._isUserReadOnly && !viewSessionFiles[i]._isMonitoring) ? TEXT("yes") : TEXT("no")); (fileNameNode->ToElement())->SetAttribute(TEXT("filename"), viewSessionFiles[i]._fileName.c_str()); (fileNameNode->ToElement())->SetAttribute(TEXT("backupFilePath"), viewSessionFiles[i]._backupFilePath.c_str()); (fileNameNode->ToElement())->SetAttribute(TEXT("originalFileLastModifTimestamp"), static_cast(viewSessionFiles[i]._originalFileLastModifTimestamp.dwLowDateTime)); diff --git a/PowerEditor/src/Parameters.h b/PowerEditor/src/Parameters.h index 5513cbd9..fb879798 100644 --- a/PowerEditor/src/Parameters.h +++ b/PowerEditor/src/Parameters.h @@ -162,8 +162,8 @@ private: struct sessionFileInfo : public Position { - sessionFileInfo(const TCHAR *fn, const TCHAR *ln, int encoding, const Position& pos, const TCHAR *backupFilePath, FILETIME originalFileLastModifTimestamp, const MapPosition & mapPos) : - _encoding(encoding), Position(pos), _originalFileLastModifTimestamp(originalFileLastModifTimestamp), _mapPos(mapPos) + sessionFileInfo(const TCHAR *fn, const TCHAR *ln, int encoding, bool userReadOnly, const Position& pos, const TCHAR *backupFilePath, FILETIME originalFileLastModifTimestamp, const MapPosition & mapPos) : + _isUserReadOnly(userReadOnly), _encoding(encoding), Position(pos), _originalFileLastModifTimestamp(originalFileLastModifTimestamp), _mapPos(mapPos) { if (fn) _fileName = fn; if (ln) _langName = ln; @@ -177,6 +177,8 @@ struct sessionFileInfo : public Position std::vector _marks; std::vector _foldStates; int _encoding = -1; + bool _isUserReadOnly = false; + bool _isMonitoring = false; generic_string _backupFilePath; FILETIME _originalFileLastModifTimestamp = {};