From 9b95f92729db3bc60784b51bf06a01fa3642dce2 Mon Sep 17 00:00:00 2001 From: tom-englert Date: Sat, 28 Sep 2024 10:28:58 +0200 Subject: [PATCH] Fix possible ObservableCollection re-entrance crash when trying to navigate to a collapsed item. --- ILSpy/AssemblyTree/AssemblyTreeModel.cs | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/ILSpy/AssemblyTree/AssemblyTreeModel.cs b/ILSpy/AssemblyTree/AssemblyTreeModel.cs index 263d81d55f..91cf6f0941 100644 --- a/ILSpy/AssemblyTree/AssemblyTreeModel.cs +++ b/ILSpy/AssemblyTree/AssemblyTreeModel.cs @@ -530,14 +530,22 @@ internal void SelectNodes(IEnumerable nodes) if (this.isNavigatingHistory) { SelectedItems.Clear(); - SelectedItems.AddRange(nodesList); + foreach (var node in nodesList) + { + activeView.ScrollIntoView(node); + SelectedItems.Add(node); + } } else { // defer selection change, so it does not interfere with the focus of the tab page. Dispatcher.BeginInvoke(() => { SelectedItems.Clear(); - SelectedItems.AddRange(nodesList); + foreach (var node in nodesList) + { + activeView.ScrollIntoView(node); + SelectedItems.Add(node); + } }); } } @@ -691,6 +699,7 @@ public void LoadAssemblies(IEnumerable fileNames, List l if (node != null && focusNode) { lastNode = node; + activeView?.ScrollIntoView(node); SelectedItems.Add(node); } }