From d6cadd963d544e2985cb6d4dc464adbe10616ef8 Mon Sep 17 00:00:00 2001 From: Matt Parker <61717342+MattParkerDev@users.noreply.github.com> Date: Thu, 30 Oct 2025 01:02:45 +1000 Subject: [PATCH] refactor opening diagnostic location --- src/SharpIDE.Godot/Features/Problems/ProblemsPanel.cs | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) 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