From 2e9598b2179811b45c40b77c3312cd75c29edc29 Mon Sep 17 00:00:00 2001 From: Matt Parker <61717342+MattParkerDev@users.noreply.github.com> Date: Wed, 22 Oct 2025 20:15:04 +1000 Subject: [PATCH] store each solutions open tabs --- .../Features/CodeEditor/CodeEditorPanel.cs | 16 +++++++++++++++- .../Features/IdeSettings/AppState.cs | 1 + .../Features/IdeSettings/IdeSolutionState.cs | 13 +++++++++++++ src/SharpIDE.Godot/IdeWindow.cs | 2 +- 4 files changed, 30 insertions(+), 2 deletions(-) create mode 100644 src/SharpIDE.Godot/Features/IdeSettings/IdeSolutionState.cs diff --git a/src/SharpIDE.Godot/Features/CodeEditor/CodeEditorPanel.cs b/src/SharpIDE.Godot/Features/CodeEditor/CodeEditorPanel.cs index 086ce58..60575e3 100644 --- a/src/SharpIDE.Godot/Features/CodeEditor/CodeEditorPanel.cs +++ b/src/SharpIDE.Godot/Features/CodeEditor/CodeEditorPanel.cs @@ -7,6 +7,7 @@ using SharpIDE.Application.Features.Events; using SharpIDE.Application.Features.Run; using SharpIDE.Application.Features.SolutionDiscovery; using SharpIDE.Application.Features.SolutionDiscovery.VsPersistence; +using SharpIDE.Godot.Features.IdeSettings; namespace SharpIDE.Godot.Features.CodeEditor; @@ -30,7 +31,20 @@ public partial class CodeEditorPanel : MarginContainer tabBar.TabClosePressed += OnTabClosePressed; GlobalEvents.Instance.DebuggerExecutionStopped.Subscribe(OnDebuggerExecutionStopped); } - + + public override void _ExitTree() + { + var thisSolution = Singletons.AppState.RecentSlns.Single(s => s.FilePath == Solution.FilePath); + thisSolution.IdeSolutionState.OpenTabs = _tabContainer.GetChildren().OfType() + .Select(t => new OpenTab + { + FilePath = t.SharpIdeFile.Path, + CaretLine = t.GetCaretLine(), + CaretColumn = t.GetCaretColumn() + }) + .ToList(); + } + public override void _UnhandledKeyInput(InputEvent @event) { if (@event.IsActionPressed(InputStringNames.StepOver)) diff --git a/src/SharpIDE.Godot/Features/IdeSettings/AppState.cs b/src/SharpIDE.Godot/Features/IdeSettings/AppState.cs index 83f70dc..00ae52d 100644 --- a/src/SharpIDE.Godot/Features/IdeSettings/AppState.cs +++ b/src/SharpIDE.Godot/Features/IdeSettings/AppState.cs @@ -16,4 +16,5 @@ public record RecentSln { public required string Name { get; set; } public required string FilePath { get; set; } + public IdeSolutionState IdeSolutionState { get; set; } = new IdeSolutionState(); } \ No newline at end of file diff --git a/src/SharpIDE.Godot/Features/IdeSettings/IdeSolutionState.cs b/src/SharpIDE.Godot/Features/IdeSettings/IdeSolutionState.cs new file mode 100644 index 0000000..401ac55 --- /dev/null +++ b/src/SharpIDE.Godot/Features/IdeSettings/IdeSolutionState.cs @@ -0,0 +1,13 @@ +namespace SharpIDE.Godot.Features.IdeSettings; + +public class IdeSolutionState +{ + public List OpenTabs { get; set; } = []; +} + +public class OpenTab +{ + public required string FilePath { get; set; } + public required int CaretLine { get; set; } + public required int CaretColumn { get; set; } +} \ No newline at end of file diff --git a/src/SharpIDE.Godot/IdeWindow.cs b/src/SharpIDE.Godot/IdeWindow.cs index 4ce0c9d..eec1127 100644 --- a/src/SharpIDE.Godot/IdeWindow.cs +++ b/src/SharpIDE.Godot/IdeWindow.cs @@ -82,7 +82,7 @@ public partial class IdeWindow : Control } ideRoot.SetSlnFilePath(slnPath); var recentSln = new RecentSln { FilePath = slnPath, Name = Path.GetFileName(slnPath) }; - Singletons.AppState.RecentSlns.RemoveAll(s => s == recentSln); // Move to end (most recent) + Singletons.AppState.RecentSlns.RemoveAll(s => s.FilePath == recentSln.FilePath); // Move to end (most recent) Singletons.AppState.RecentSlns.Add(recentSln); await this.InvokeAsync(() =>