From 8a1bf9df1075ebc6a6a218248e3dfcd1c98d215c Mon Sep 17 00:00:00 2001 From: Matt Parker <61717342+MattParkerDev@users.noreply.github.com> Date: Thu, 9 Oct 2025 01:15:22 +1000 Subject: [PATCH] Save open files on window focus loss --- src/SharpIDE.Godot/IdeWindow.cs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/SharpIDE.Godot/IdeWindow.cs b/src/SharpIDE.Godot/IdeWindow.cs index b7360c9..7ead535 100644 --- a/src/SharpIDE.Godot/IdeWindow.cs +++ b/src/SharpIDE.Godot/IdeWindow.cs @@ -27,6 +27,7 @@ public partial class IdeWindow : Control MSBuildLocator.RegisterDefaults(); GodotServiceDefaults.AddServiceDefaults(); Singletons.AppState = AppStateLoader.LoadAppStateFromConfigFile(); + GetWindow().FocusExited += OnFocusExited; //GetWindow().SetMinSize(new Vector2I(1152, 648)); Callable.From(() => PickSolution(true)).CallDeferred(); } @@ -42,6 +43,11 @@ public partial class IdeWindow : Control // PrintOrphanNodes(); } + private void OnFocusExited() + { + _ = Task.GodotRun(async () => await Singletons.FileManager.SaveAllOpenFilesAsync()); + } + public void PickSolution(bool fullscreen = false) { if (_slnPicker is not null) throw new InvalidOperationException("Solution picker is already active");