Skip to content

Commit

Permalink
Fix issue WinMerge#2359: Selected files changes on expanding a folder…
Browse files Browse the repository at this point in the history
… that is upper on the tree
  • Loading branch information
sdottaka committed Jun 21, 2024
1 parent 79e0650 commit 54a19f1
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion Src/DirView.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1253,6 +1253,8 @@ void CDirView::ExpandSubdir(int sel, bool bRecursive)

m_pList->SetRedraw(FALSE); // Turn off updating (better performance)

size_t oldItemCount = m_listViewItems.size();

CDiffContext &ctxt = GetDiffContext();
dip.customFlags |= ViewCustomFlags::EXPANDED;
if (bRecursive)
Expand All @@ -1265,8 +1267,18 @@ void CDirView::ExpandSubdir(int sel, bool bRecursive)

SortColumnsAppropriately();

if (m_pList->GetNextItem(sel, LVNI_SELECTED) != -1)
{
LVITEM lvi {0, sel + 1};
for (size_t i = 0; i < m_listViewItems.size() - oldItemCount; i++)
m_pList->InsertItem(&lvi);
}
else
{
m_pList->SetItemCountEx(static_cast<int>(m_listViewItems.size()), LVSICF_NOSCROLL);
}

m_pList->SetRedraw(TRUE); // Turn updating back on
m_pList->SetItemCountEx(static_cast<int>(m_listViewItems.size()), LVSICF_NOSCROLL);
m_pList->Invalidate();
}

Expand Down

0 comments on commit 54a19f1

Please sign in to comment.