Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix renaming process in folder compare window. #1392

Merged
merged 1 commit into from Jul 3, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
25 changes: 25 additions & 0 deletions Src/DirView.cpp
Expand Up @@ -48,6 +48,7 @@
#include "PatchTool.h"
#include "SyntaxColors.h"
#include "Shell.h"
#include "DirTravel.h"
#include <numeric>
#include <functional>

Expand Down Expand Up @@ -3410,7 +3411,31 @@ afx_msg void CDirView::OnEndLabelEdit(NMHDR* pNMHDR, LRESULT* pResult)
{
try {
DirItemIterator it(m_pIList.get(), reinterpret_cast<NMLVDISPINFO *>(pNMHDR)->item.iItem);
DIFFITEM& di = *it;
unsigned sideFlags = (di.diffcode.diffcode & DIFFCODE::SIDEFLAGS);
*pResult = DoItemRename(it, GetDiffContext(), String(sText));
// Rescan the item if side flags change due to renaming.
if (*pResult && ((di.diffcode.diffcode & DIFFCODE::SIDEFLAGS) != sideFlags))
{
// Delete the item with the same file name as after renaming.
if (di.HasParent())
{
for (DIFFITEM* pItem = di.GetParentLink()->GetFirstChild(); pItem != nullptr; pItem = pItem->GetFwdSiblingLink())
{
if ((pItem != &di) && (pItem->diffcode.isDirectory() == di.diffcode.isDirectory()) && (collstr(pItem->diffFileInfo[0].filename, di.diffFileInfo[0].filename, false) == 0))
{
pItem->DelinkFromSiblings();
delete pItem;
break;
}
}
}
// Rescan the item.
MarkForRescan(di);
m_pSavedTreeState.reset(SaveTreeState(GetDiffContext()));
GetDocument()->SetMarkedRescan();
GetDocument()->Rescan();
}
} catch (ContentsChangedException& e) {
AfxMessageBox(e.m_msg.c_str(), MB_ICONWARNING);
}
Expand Down