Skip to content

Commit

Permalink
Fix cloned (modified & unsaved) document disassociated issue after Np…
Browse files Browse the repository at this point in the history
…p being relaunched

The bug has been fixed in v8.5.7 by PR notepad-plus-plus#14003.
However the fix causes a regression notepad-plus-plus#14164, the concerning commit is reverted.
Hence this fix.

Fix notepad-plus-plus#10266, fix notepad-plus-plus#10365
  • Loading branch information
donho committed Dec 5, 2023
1 parent 6f2e5d2 commit a51e62c
Showing 1 changed file with 12 additions and 7 deletions.
19 changes: 12 additions & 7 deletions PowerEditor/src/NppIO.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2276,17 +2276,21 @@ bool Notepad_plus::loadSession(Session & session, bool isSnapshotMode, const wch
nppParam.safeWow64EnableWow64FsRedirection(FALSE);
isWow64Off = true;
}

if (PathFileExists(pFn))
{
if (isSnapshotMode && session._subViewFiles[k]._backupFilePath != TEXT(""))
lastOpened = doOpen(pFn, false, false, session._subViewFiles[k]._encoding, session._subViewFiles[k]._backupFilePath.c_str(), session._subViewFiles[k]._originalFileLastModifTimestamp);
else
lastOpened = doOpen(pFn, false, false, session._subViewFiles[k]._encoding);

//check if already open in main. If so, clone
if (_mainDocTab.getIndexByBuffer(lastOpened) != -1)
BufferID clonedBuf = _mainDocTab.findBufferByName(pFn);
if (clonedBuf != BUFFER_INVALID)
{
loadBufferIntoView(clonedBuf, SUB_VIEW);
}
else
{
loadBufferIntoView(lastOpened, SUB_VIEW);
if (isSnapshotMode && session._subViewFiles[k]._backupFilePath != TEXT(""))
lastOpened = doOpen(pFn, false, false, session._subViewFiles[k]._encoding, session._subViewFiles[k]._backupFilePath.c_str(), session._subViewFiles[k]._originalFileLastModifTimestamp);
else
lastOpened = doOpen(pFn, false, false, session._subViewFiles[k]._encoding);
}
}
else if (isSnapshotMode && PathFileExists(session._subViewFiles[k]._backupFilePath.c_str()))
Expand All @@ -2299,6 +2303,7 @@ bool Notepad_plus::loadSession(Session & session, bool isSnapshotMode, const wch
if (foundBufID == BUFFER_INVALID)
lastOpened = nppGUI._keepSessionAbsentFileEntries ? MainFileManager.newPlaceholderDocument(pFn, SUB_VIEW, userCreatedSessionName) : BUFFER_INVALID;
}

if (isWow64Off)
{
nppParam.safeWow64EnableWow64FsRedirection(TRUE);
Expand Down

0 comments on commit a51e62c

Please sign in to comment.