open previously open files

This commit is contained in:
Matt Parker
2025-10-22 20:55:09 +10:00
parent 2e9598b217
commit aec76cc10e
4 changed files with 27 additions and 6 deletions

View File

@@ -1,7 +1,15 @@
namespace SharpIDE.Application.Features.Analysis; using System.Diagnostics.CodeAnalysis;
namespace SharpIDE.Application.Features.Analysis;
public struct SharpIdeFileLinePosition public struct SharpIdeFileLinePosition
{ {
[SetsRequiredMembers]
public SharpIdeFileLinePosition(int line, int column)
{
Line = line;
Column = column;
}
public required int Line { get; set; } public required int Line { get; set; }
public required int Column { get; set; } public required int Column { get; set; }
} }

View File

@@ -0,0 +1 @@
uid://bbrr8py0cemp0

View File

@@ -151,9 +151,17 @@ public partial class IdeRoot : Control
_roslynAnalysis.StartSolutionAnalysis(solutionModel); _roslynAnalysis.StartSolutionAnalysis(solutionModel);
_fileWatcher.StartWatching(solutionModel); _fileWatcher.StartWatching(solutionModel);
var infraProject = solutionModel.AllProjects.SingleOrDefault(s => s.Name == "WebUi"); var previousTabs = Singletons.AppState.RecentSlns.Single(s => s.FilePath == solutionModel.FilePath).IdeSolutionState.OpenTabs;
var diFile = infraProject?.Folders.Single(s => s.Name == "Pages").Files.Single(s => s.Name == "TestPage.razor"); var filesToOpen = previousTabs
if (diFile != null) await this.InvokeDeferredAsync(() => GodotGlobalEvents.Instance.FileExternallySelected.InvokeParallelFireAndForget(diFile, null)); .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(); var tasks = solutionModel.AllProjects.Select(p => p.MsBuildEvaluationProjectTask).ToList();
await Task.WhenAll(tasks).ConfigureAwait(false); await Task.WhenAll(tasks).ConfigureAwait(false);

View File

@@ -81,8 +81,12 @@ public partial class IdeWindow : Control
return; return;
} }
ideRoot.SetSlnFilePath(slnPath); ideRoot.SetSlnFilePath(slnPath);
var recentSln = new RecentSln { FilePath = slnPath, Name = Path.GetFileName(slnPath) }; var recentSln = Singletons.AppState.RecentSlns.SingleOrDefault(s => s.FilePath == slnPath);
Singletons.AppState.RecentSlns.RemoveAll(s => s.FilePath == recentSln.FilePath); // Move to end (most recent) if (recentSln is not null)
{
Singletons.AppState.RecentSlns.Remove(recentSln);
}
recentSln ??= new RecentSln { FilePath = slnPath, Name = Path.GetFileName(slnPath)};
Singletons.AppState.RecentSlns.Add(recentSln); Singletons.AppState.RecentSlns.Add(recentSln);
await this.InvokeAsync(() => await this.InvokeAsync(() =>