mirror of
https://github.com/notepad-plus-plus/notepad-plus-plus.git
synced 2025-07-27 07:44:24 +02:00
Fix unsaved documents lost on next launch if portable npp change path
When Notepad++ portable version changes its path (move/rename), the periode backup files (unsaved documents) are lost on the next session, due to the absolute paths in session files. This commit fixes the issue by ensuring the backup path matches with such documents. Fix #1587, fix #15886, close #15942
This commit is contained in:
parent
dc583bf34e
commit
10ae99e790
@ -2430,7 +2430,20 @@ bool NppParameters::getSessionFromXmlTree(TiXmlDocument *pSessionDoc, Session& s
|
|||||||
langName = (childNode->ToElement())->Attribute(L"lang");
|
langName = (childNode->ToElement())->Attribute(L"lang");
|
||||||
int encoding = -1;
|
int encoding = -1;
|
||||||
const wchar_t *encStr = (childNode->ToElement())->Attribute(L"encoding", &encoding);
|
const wchar_t *encStr = (childNode->ToElement())->Attribute(L"encoding", &encoding);
|
||||||
const wchar_t *backupFilePath = (childNode->ToElement())->Attribute(L"backupFilePath");
|
|
||||||
|
const wchar_t *pBackupFilePath = (childNode->ToElement())->Attribute(L"backupFilePath");
|
||||||
|
std::wstring currentBackupFilePath = NppParameters::getInstance().getUserPath() + L"\\backup\\";
|
||||||
|
if (pBackupFilePath)
|
||||||
|
{
|
||||||
|
std::wstring backupFilePath = pBackupFilePath;
|
||||||
|
if (!backupFilePath.starts_with(currentBackupFilePath))
|
||||||
|
{
|
||||||
|
// reconstruct backupFilePath
|
||||||
|
wchar_t* fn = PathFindFileName(pBackupFilePath);
|
||||||
|
currentBackupFilePath += fn;
|
||||||
|
pBackupFilePath = currentBackupFilePath.c_str();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
FILETIME fileModifiedTimestamp{};
|
FILETIME fileModifiedTimestamp{};
|
||||||
(childNode->ToElement())->Attribute(L"originalFileLastModifTimestamp", reinterpret_cast<int32_t*>(&fileModifiedTimestamp.dwLowDateTime));
|
(childNode->ToElement())->Attribute(L"originalFileLastModifTimestamp", reinterpret_cast<int32_t*>(&fileModifiedTimestamp.dwLowDateTime));
|
||||||
@ -2446,7 +2459,7 @@ bool NppParameters::getSessionFromXmlTree(TiXmlDocument *pSessionDoc, Session& s
|
|||||||
if (boolStrPinned)
|
if (boolStrPinned)
|
||||||
isPinned = _wcsicmp(L"yes", boolStrPinned) == 0;
|
isPinned = _wcsicmp(L"yes", boolStrPinned) == 0;
|
||||||
|
|
||||||
sessionFileInfo sfi(fileName, langName, encStr ? encoding : -1, isUserReadOnly, isPinned, position, backupFilePath, fileModifiedTimestamp, mapPosition);
|
sessionFileInfo sfi(fileName, langName, encStr ? encoding : -1, isUserReadOnly, isPinned, position, pBackupFilePath, fileModifiedTimestamp, mapPosition);
|
||||||
|
|
||||||
const wchar_t* intStrTabColour = (childNode->ToElement())->Attribute(L"tabColourId");
|
const wchar_t* intStrTabColour = (childNode->ToElement())->Attribute(L"tabColourId");
|
||||||
if (intStrTabColour)
|
if (intStrTabColour)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user