store each solutions open tabs

This commit is contained in:
Matt Parker
2025-10-22 20:15:04 +10:00
parent 7ac3947563
commit 2e9598b217
4 changed files with 30 additions and 2 deletions

View File

@@ -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<SharpIdeCodeEdit>()
.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))

View File

@@ -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();
}

View File

@@ -0,0 +1,13 @@
namespace SharpIDE.Godot.Features.IdeSettings;
public class IdeSolutionState
{
public List<OpenTab> OpenTabs { get; set; } = [];
}
public class OpenTab
{
public required string FilePath { get; set; }
public required int CaretLine { get; set; }
public required int CaretColumn { get; set; }
}

View File

@@ -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(() =>