diff --git a/src/SharpIDE.Godot/Features/BottomPanel/BottomPanelManager.cs b/src/SharpIDE.Godot/Features/BottomPanel/BottomPanelManager.cs index 09bf9eb..d195205 100644 --- a/src/SharpIDE.Godot/Features/BottomPanel/BottomPanelManager.cs +++ b/src/SharpIDE.Godot/Features/BottomPanel/BottomPanelManager.cs @@ -12,16 +12,6 @@ namespace SharpIDE.Godot.Features.BottomPanel; public partial class BottomPanelManager : Panel { - public SharpIdeSolutionModel? Solution - { - get; - set - { - field = value; - _problemsPanel.Solution = value; - } - } - private RunPanel _runPanel = null!; private DebugPanel _debugPanel = null!; private BuildPanel _buildPanel = null!; diff --git a/src/SharpIDE.Godot/Features/Problems/ProblemsPanel.cs b/src/SharpIDE.Godot/Features/Problems/ProblemsPanel.cs index 43e2950..21d8366 100644 --- a/src/SharpIDE.Godot/Features/Problems/ProblemsPanel.cs +++ b/src/SharpIDE.Godot/Features/Problems/ProblemsPanel.cs @@ -4,7 +4,6 @@ using Microsoft.CodeAnalysis; using ObservableCollections; using R3; using SharpIDE.Application.Features.Analysis; -using SharpIDE.Application.Features.SolutionDiscovery; using SharpIDE.Application.Features.SolutionDiscovery.VsPersistence; using SharpIDE.Godot.Features.Common; @@ -18,8 +17,10 @@ public partial class ProblemsPanel : Control public Texture2D ErrorIcon { get; set; } = null!; [Export] public Texture2D CsprojIcon { get; set; } = null!; + + private SharpIdeSolutionModel? _solution; - public SharpIdeSolutionModel? Solution { get; set; } + [Inject] private readonly SharpIdeSolutionAccessor _sharpIdeSolutionAccessor = null!; private Tree _tree = null!; private TreeItem _rootItem = null!; @@ -33,16 +34,16 @@ public partial class ProblemsPanel : Control _tree.ItemActivated += TreeOnItemActivated; _rootItem = _tree.CreateItem(); _rootItem.SetText(0, "Problems"); - Observable.EveryValueChanged(this, manager => manager.Solution) - .Where(s => s is not null) - .Subscribe(s => - { - _projects.RemoveRange(_projects); - _projects.AddRange(s!.AllProjects); - }).AddTo(this); BindToTree(_projects); + _ = Task.GodotRun(AsyncReady); } + private async Task AsyncReady() + { + await _sharpIdeSolutionAccessor.SolutionReadyTcs.Task; + _solution = _sharpIdeSolutionAccessor.SolutionModel; + _projects.AddRange(_solution!.AllProjects); + } public void BindToTree(ObservableHashSet list) { @@ -195,14 +196,13 @@ public partial class ProblemsPanel : Control var parentTreeItem = selected.GetParent(); var projectContainer = parentTreeItem.GetMetadata(0).As?>(); if (projectContainer is null) return; - OpenDocumentContainingDiagnostic(diagnostic.Diagnostic); + OpenDocumentContainingDiagnostic(diagnostic); } - private void OpenDocumentContainingDiagnostic(Diagnostic diagnostic) + private void OpenDocumentContainingDiagnostic(SharpIdeDiagnostic diagnostic) { - var fileLinePositionSpan = diagnostic.Location.GetMappedLineSpan(); - var file = Solution!.AllFiles[fileLinePositionSpan.Path]; - var linePosition = new SharpIdeFileLinePosition(fileLinePositionSpan.StartLinePosition.Line, fileLinePositionSpan.StartLinePosition.Character); + var file = _solution!.AllFiles[diagnostic.FilePath]; + var linePosition = new SharpIdeFileLinePosition(diagnostic.Span.Start.Line, diagnostic.Span.Start.Character); GodotGlobalEvents.Instance.FileExternallySelected.InvokeParallelFireAndForget(file, linePosition); } } \ No newline at end of file diff --git a/src/SharpIDE.Godot/IdeRoot.cs b/src/SharpIDE.Godot/IdeRoot.cs index 1b4505b..0666236 100644 --- a/src/SharpIDE.Godot/IdeRoot.cs +++ b/src/SharpIDE.Godot/IdeRoot.cs @@ -152,7 +152,6 @@ public partial class IdeRoot : Control _sharpIdeSolutionAccessor.SolutionReadyTcs.SetResult(); _solutionExplorerPanel.SolutionModel = solutionModel; _codeEditorPanel.Solution = solutionModel; - _bottomPanelManager.Solution = solutionModel; _searchWindow.Solution = solutionModel; _searchAllFilesWindow.Solution = solutionModel; _fileExternalChangeHandler.SolutionModel = solutionModel;