OSDN Git Service

Folder Compare:
authorTakashi Sawanaka <sdottaka@users.sourceforge.net>
Sat, 12 Nov 2022 14:17:58 +0000 (23:17 +0900)
committerTakashi Sawanaka <sdottaka@users.sourceforge.net>
Sat, 12 Nov 2022 14:17:58 +0000 (23:17 +0900)
- Fix osdn.net #46061: Fix problem with scrolling to unexpected position when expanding folders
- Fix the problem of moving the selection when a folder is expanded

Src/DirView.cpp

index 17130f4..a73ed36 100644 (file)
@@ -1241,6 +1241,9 @@ void CDirView::ExpandSubdir(int sel, bool bRecursive)
 
        m_pList->SetRedraw(FALSE);      // Turn off updating (better performance)
 
+       const int top = m_pList->GetTopIndex();
+       const size_t num = m_listViewItems.size();
+
        CDiffContext &ctxt = GetDiffContext();
        dip.customFlags |= ViewCustomFlags::EXPANDED;
        if (bRecursive)
@@ -1251,10 +1254,14 @@ void CDirView::ExpandSubdir(int sel, bool bRecursive)
        int alldiffs;
        RedisplayChildren(diffpos, dip.GetDepth() + 1, indext, alldiffs);
 
+       for (size_t i = 0; i < m_listViewItems.size() - num; ++i)
+               m_pList->InsertItem(sel + 1, nullptr);
+
        SortColumnsAppropriately();
 
        m_pList->SetRedraw(TRUE);       // Turn updating back on
        m_pList->SetItemCount(static_cast<int>(m_listViewItems.size()));
+       m_pList->EnsureVisible(top, TRUE);
        m_pList->Invalidate();
 }