diff --git a/src/SharpIDE.Application/Features/Analysis/SharpIdeFileLinePosition.cs b/src/SharpIDE.Application/Features/Analysis/SharpIdeFileLinePosition.cs index b471185..490be43 100644 --- a/src/SharpIDE.Application/Features/Analysis/SharpIdeFileLinePosition.cs +++ b/src/SharpIDE.Application/Features/Analysis/SharpIdeFileLinePosition.cs @@ -1,7 +1,15 @@ -namespace SharpIDE.Application.Features.Analysis; +using System.Diagnostics.CodeAnalysis; + +namespace SharpIDE.Application.Features.Analysis; public struct SharpIdeFileLinePosition { + [SetsRequiredMembers] + public SharpIdeFileLinePosition(int line, int column) + { + Line = line; + Column = column; + } public required int Line { get; set; } public required int Column { get; set; } } diff --git a/src/SharpIDE.Godot/Features/IdeSettings/IdeSolutionState.cs.uid b/src/SharpIDE.Godot/Features/IdeSettings/IdeSolutionState.cs.uid new file mode 100644 index 0000000..14315a6 --- /dev/null +++ b/src/SharpIDE.Godot/Features/IdeSettings/IdeSolutionState.cs.uid @@ -0,0 +1 @@ +uid://bbrr8py0cemp0 diff --git a/src/SharpIDE.Godot/IdeRoot.cs b/src/SharpIDE.Godot/IdeRoot.cs index 9a02c19..a43d548 100644 --- a/src/SharpIDE.Godot/IdeRoot.cs +++ b/src/SharpIDE.Godot/IdeRoot.cs @@ -151,9 +151,17 @@ public partial class IdeRoot : Control _roslynAnalysis.StartSolutionAnalysis(solutionModel); _fileWatcher.StartWatching(solutionModel); - var infraProject = solutionModel.AllProjects.SingleOrDefault(s => s.Name == "WebUi"); - var diFile = infraProject?.Folders.Single(s => s.Name == "Pages").Files.Single(s => s.Name == "TestPage.razor"); - if (diFile != null) await this.InvokeDeferredAsync(() => GodotGlobalEvents.Instance.FileExternallySelected.InvokeParallelFireAndForget(diFile, null)); + var previousTabs = Singletons.AppState.RecentSlns.Single(s => s.FilePath == solutionModel.FilePath).IdeSolutionState.OpenTabs; + var filesToOpen = previousTabs + .Select(s => (solutionModel.AllFiles.Single(f => f.Path == s.FilePath), new SharpIdeFileLinePosition(s.CaretLine, s.CaretColumn))) + .ToList(); + await this.InvokeDeferredAsync(async () => + { + foreach (var (file, linePosition) in filesToOpen) + { + GodotGlobalEvents.Instance.FileExternallySelected.InvokeParallelFireAndForget(file, linePosition); + } + }); var tasks = solutionModel.AllProjects.Select(p => p.MsBuildEvaluationProjectTask).ToList(); await Task.WhenAll(tasks).ConfigureAwait(false); diff --git a/src/SharpIDE.Godot/IdeWindow.cs b/src/SharpIDE.Godot/IdeWindow.cs index eec1127..ab9ba55 100644 --- a/src/SharpIDE.Godot/IdeWindow.cs +++ b/src/SharpIDE.Godot/IdeWindow.cs @@ -81,8 +81,12 @@ public partial class IdeWindow : Control return; } ideRoot.SetSlnFilePath(slnPath); - var recentSln = new RecentSln { FilePath = slnPath, Name = Path.GetFileName(slnPath) }; - Singletons.AppState.RecentSlns.RemoveAll(s => s.FilePath == recentSln.FilePath); // Move to end (most recent) + var recentSln = Singletons.AppState.RecentSlns.SingleOrDefault(s => s.FilePath == slnPath); + if (recentSln is not null) + { + Singletons.AppState.RecentSlns.Remove(recentSln); + } + recentSln ??= new RecentSln { FilePath = slnPath, Name = Path.GetFileName(slnPath)}; Singletons.AppState.RecentSlns.Add(recentSln); await this.InvokeAsync(() =>