diff --git a/src/SharpIDE.Application/Features/Analysis/RoslynAnalysis.cs b/src/SharpIDE.Application/Features/Analysis/RoslynAnalysis.cs index fa871c6..53f32a6 100644 --- a/src/SharpIDE.Application/Features/Analysis/RoslynAnalysis.cs +++ b/src/SharpIDE.Application/Features/Analysis/RoslynAnalysis.cs @@ -81,12 +81,7 @@ public static class RoslynAnalysis _codeFixProviders = _codeFixProviders.DistinctBy(s => s.GetType().Name).ToHashSet(); _codeRefactoringProviders = _codeRefactoringProviders.DistinctBy(s => s.GetType().Name).ToHashSet(); - foreach (var project in _sharpIdeSolutionModel.AllProjects) - { - var projectDiagnostics = await GetProjectDiagnostics(project); - project.Diagnostics.Clear(); - project.Diagnostics.AddRange(projectDiagnostics); - } + await UpdateSolutionDiagnostics(); foreach (var project in solution.Projects) { // foreach (var document in project.Documents) @@ -112,6 +107,18 @@ public static class RoslynAnalysis Console.WriteLine("RoslynAnalysis: Analysis completed."); } + public static async Task UpdateSolutionDiagnostics() + { + await _solutionLoadedTcs.Task; + foreach (var project in _sharpIdeSolutionModel!.AllProjects) + { + var projectDiagnostics = await GetProjectDiagnostics(project); + // TODO: only add and remove diffs + project.Diagnostics.RemoveRange(project.Diagnostics); + project.Diagnostics.AddRange(projectDiagnostics); + } + } + public static async Task> GetProjectDiagnostics(SharpIdeProjectModel projectModel) { await _solutionLoadedTcs.Task; diff --git a/src/SharpIDE.Godot/Features/Problems/ProblemsPanel.cs b/src/SharpIDE.Godot/Features/Problems/ProblemsPanel.cs index 2a94a8b..175fc5f 100644 --- a/src/SharpIDE.Godot/Features/Problems/ProblemsPanel.cs +++ b/src/SharpIDE.Godot/Features/Problems/ProblemsPanel.cs @@ -63,12 +63,12 @@ public partial class ProblemsPanel : Control .SubscribeAwait(async (innerEvent, ct) => await (innerEvent.Action switch { NotifyCollectionChangedAction.Add => CreateDiagnosticTreeItem(_tree, treeItem, innerEvent), - NotifyCollectionChangedAction.Remove => FreeTreeItem(e.OldItem.View.Value), + NotifyCollectionChangedAction.Remove => FreeTreeItem(innerEvent.OldItem.View.Value), _ => Task.CompletedTask })).AddTo(this); }); } - + private async Task CreateDiagnosticTreeItem(Tree tree, TreeItem parent, ViewChangedEvent e) { await this.InvokeAsync(() =>