Browse Source

Merge pull request #3726 from icsharpcode/christophwille/3705

Fix #3705: Code window is empty when select a .baml and refresh
pull/3735/head
Siegfried Pammer 2 months ago committed by GitHub
parent
commit
dfc2bbb970
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 29
      ILSpy/AssemblyTree/AssemblyTreeModel.cs

29
ILSpy/AssemblyTree/AssemblyTreeModel.cs

@ -946,12 +946,41 @@ namespace ICSharpCode.ILSpy.AssemblyTree @@ -946,12 +946,41 @@ namespace ICSharpCode.ILSpy.AssemblyTree
}
private void RefreshInternal()
{
RefreshInternalAsync().HandleExceptions();
}
private async Task RefreshInternalAsync()
{
using (Keyboard.FocusedElement.PreserveFocus())
{
var path = GetPathForNode(SelectedItem);
ShowAssemblyList(settingsService.AssemblyListManager.LoadList(AssemblyList.ListName));
// Ensure the assembly is loaded before FindNodeByPath, so lazy-loaded
// resource nodes (e.g. .baml entries) are present in the tree.
if (path?.Length > 0)
{
var rootAssembly = AssemblyList.FindAssembly(path[0]);
if (rootAssembly != null)
{
// FindNodeByPath() blocks the UI if the assembly is not yet loaded,
// so use an async wait instead.
var preAwaitSelection = SelectedItem;
await rootAssembly.GetMetadataFileAsync().Catch<Exception>(_ => { });
// If the user navigated to a different node while the assembly
// was loading, respect that — don't restore the pre-refresh path.
// A change to null counts too (e.g. user cleared the selection).
if (!ReferenceEquals(SelectedItem, preAwaitSelection))
{
RefreshDecompiledView();
return;
}
}
}
SelectNode(FindNodeByPath(path, true), inNewTabPage: false);
RefreshDecompiledView();

Loading…
Cancel
Save