Fix #3705: Code window is empty when select a .baml and refresh#3726
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Fixes ILSpy issue #3705 where the code window can become empty after selecting a .baml resource and refreshing, by ensuring the relevant assembly is loaded before attempting to re-select the previously selected tree path.
Changes:
- Refactors the refresh path into an async flow so the UI can await assembly metadata loading.
- Preloads the selected assembly’s metadata before calling
FindNodeByPath, improving lookup of lazy-loaded resource nodes. - Keeps the existing refresh throttle entry point (
Refresh()→refreshThrottle.Tick()).
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
974bf9b to
dec852d
Compare
Comment on lines
948
to
+951
| private void RefreshInternal() | ||
| { | ||
| RefreshInternalAsync().HandleExceptions(); | ||
| } |
Comment on lines
+971
to
+973
| // If the user navigated to a different node while the assembly | ||
| // was loading, respect that — don't restore the pre-refresh path. | ||
| if (SelectedItem != null && !ReferenceEquals(SelectedItem, preAwaitSelection)) |
…election. Three small follow-ups to #3705's lazy-resource fix: * Replace `_ = RefreshInternalAsync()` with `RefreshInternalAsync().HandleExceptions()`. The previous fire-and- forget discard silently swallowed any exception thrown outside the explicit Catch helper on GetMetadataFileAsync; HandleExceptions is the codebase's idiomatic helper that surfaces the failure into the decompile text view. * Look up the path-root assembly via AssemblyList.FindAssembly (an O(1) hash lookup keyed by OrdinalIgnoreCase, with Path.GetFullPath canonicalisation) instead of an O(n) foreach with case-sensitive string equality. Same shape used by the rest of the codebase. * Detect the user navigating during the GetMetadataFileAsync await (which can take ~2s for a sizeable WPF assembly) and bail out of the path-restore. Without this, clicking another tree node mid- refresh would be silently overwritten when the deferred SelectNode jumped back to the captured pre-refresh path. No behavior change for the .baml refresh fix itself. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
dec852d to
4c347ef
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.