diff --git a/src/SharpIDE.Godot/Features/Problems/ProblemsPanel.cs b/src/SharpIDE.Godot/Features/Problems/ProblemsPanel.cs index ee93d5b..bcebfd2 100644 --- a/src/SharpIDE.Godot/Features/Problems/ProblemsPanel.cs +++ b/src/SharpIDE.Godot/Features/Problems/ProblemsPanel.cs @@ -112,16 +112,13 @@ public partial class ProblemsPanel : Control var parentTreeItem = selected.GetParent(); var projectContainer = parentTreeItem.GetMetadata(0).As?>(); if (projectContainer is null) return; - var projectModel = projectContainer.Item; - OpenDocumentContainingDiagnostic(diagnostic, projectModel); + OpenDocumentContainingDiagnostic(diagnostic); } - private static void OpenDocumentContainingDiagnostic(Diagnostic diagnostic, SharpIdeProjectModel projectModel) + private void OpenDocumentContainingDiagnostic(Diagnostic diagnostic) { - // TODO: probably store a flat list of all files in each project to avoid recursion - var file = projectModel.Files - .Concat(projectModel.Folders.SelectMany(f => f.GetAllFiles())) - .Single(s => s.Path == diagnostic.Location.SourceTree?.GetMappedLineSpan(diagnostic.Location.SourceSpan).Path); + var filePath = diagnostic.Location.SourceTree?.GetMappedLineSpan(diagnostic.Location.SourceSpan).Path; + var file = Solution!.AllFiles.Single(f => f.Path == filePath); GodotGlobalEvents.Instance.FileExternallySelected.InvokeParallelFireAndForget(file, null); } } \ No newline at end of file