Expand sln explorer when file is selected externally

This commit is contained in:
Matt Parker
2025-08-17 14:24:28 +10:00
parent 7f01df7369
commit 179f2ab0e4

View File

@@ -52,6 +52,21 @@
private MudMenu _contextMenuRef = null!;
private SharpIdeProjectModel? _contextMenuProject;
protected override async Task OnParametersSetAsync()
{
if (SelectedFile is null) return;
var parent = SelectedFile.Parent;
parent.Expanded = true;
while (parent is IChildSharpIdeNode childNode)
{
if (childNode is not IExpandableSharpIdeNode expandableNode) throw new InvalidOperationException("Parent node must implement IExpandableSharpIdeNode");
expandableNode.Expanded = true;
parent = childNode.Parent;
}
if (parent is not SharpIdeSolutionModel solutionModel) throw new InvalidOperationException("Parent node must be a SharpIdeSolutionModel");
solutionModel.Expanded = true;
}
private async Task InvokeSelectedFileChanged(SharpIdeFile file)
{
SelectedFile = file;