diff --git a/ICSharpCode.ILSpyX/TreeView/SharpTreeNode.cs b/ICSharpCode.ILSpyX/TreeView/SharpTreeNode.cs
index ea54bd4e1..74b66cd6b 100644
--- a/ICSharpCode.ILSpyX/TreeView/SharpTreeNode.cs
+++ b/ICSharpCode.ILSpyX/TreeView/SharpTreeNode.cs
@@ -374,6 +374,23 @@ namespace ICSharpCode.ILSpyX.TreeView
}
}
+ ///
+ /// Rebuilds the children of an already-loaded node in place: clears them, re-arms lazy
+ /// loading, and re-runs . A no-op for a node that is still lazy
+ /// (it will build fresh on first expand anyway). Use this when external state that
+ /// reads has changed and the materialized subtree must be
+ /// regenerated -- e.g. a display setting that alters the tree's shape. Like setting
+ /// , this collapses the node.
+ ///
+ public void ReloadChildren()
+ {
+ if (LazyLoading)
+ return;
+ Children.Clear();
+ LazyLoading = true;
+ EnsureLazyChildren();
+ }
+
#endregion
#region Ancestors / Descendants
diff --git a/ILSpy/AssemblyTree/AssemblyTreeModel.cs b/ILSpy/AssemblyTree/AssemblyTreeModel.cs
index 950074275..23b6412e1 100644
--- a/ILSpy/AssemblyTree/AssemblyTreeModel.cs
+++ b/ILSpy/AssemblyTree/AssemblyTreeModel.cs
@@ -264,15 +264,9 @@ namespace ILSpy.AssemblyTree
break;
case nameof(Options.DisplaySettings.UseNestedNamespaceNodes):
// Tree shape changes — every loaded AssemblyTreeNode's namespace subtree
- // needs rebuilding. Reset Children + LazyLoading and re-trigger the load.
+ // needs rebuilding.
foreach (var asm in Root.Children.OfType())
- {
- if (asm.LazyLoading)
- continue;
- asm.Children.Clear();
- asm.LazyLoading = true;
- asm.EnsureLazyChildren();
- }
+ asm.ReloadChildren();
// AssemblyListPane caches a snapshot of each expanded node's children via
// the HierarchicalOptions.ChildrenSelector — mid-expand mutations of
// node.Children aren't observed. Re-raising Root forces BindTree to fire,
@@ -294,12 +288,7 @@ namespace ILSpy.AssemblyTree
{
if (node is Metadata.MetadataTablesTreeNode tables)
{
- if (!tables.LazyLoading)
- {
- tables.Children.Clear();
- tables.LazyLoading = true;
- tables.EnsureLazyChildren();
- }
+ tables.ReloadChildren();
return;
}
if (node.LazyLoading)