From c547586533135915bc099ca0775ab6d39add240a Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sun, 26 Oct 2025 20:47:52 +0000 Subject: [PATCH] Fix ResetState to properly reset all fields - Reset EndAfterFirstIteration and ClearScreenNextIteration - Reset Iteration event - Reset _forceFakeConsole field - Reset _supportedCultures field Co-authored-by: tig <585482+tig@users.noreply.github.com> --- Terminal.Gui/App/Application.Driver.cs | 6 ++++++ Terminal.Gui/App/Application.Run.cs | 1 + Terminal.Gui/App/ApplicationImpl.cs | 8 ++++++++ 3 files changed, 15 insertions(+) diff --git a/Terminal.Gui/App/Application.Driver.cs b/Terminal.Gui/App/Application.Driver.cs index aa2ee80fe..3671ee519 100644 --- a/Terminal.Gui/App/Application.Driver.cs +++ b/Terminal.Gui/App/Application.Driver.cs @@ -6,6 +6,12 @@ public static partial class Application // Driver abstractions { internal static bool _forceFakeConsole; + // Internal helper method for ApplicationImpl.ResetState to clear this field + internal static void ClearForceFakeConsole () + { + _forceFakeConsole = false; + } + /// Gets the that has been selected. See also . public static IConsoleDriver? Driver { diff --git a/Terminal.Gui/App/Application.Run.cs b/Terminal.Gui/App/Application.Run.cs index 2aba0f7e3..d6dbb6728 100644 --- a/Terminal.Gui/App/Application.Run.cs +++ b/Terminal.Gui/App/Application.Run.cs @@ -46,6 +46,7 @@ public static partial class Application // Run (Begin -> Run -> Layout/Draw -> E { NotifyNewRunState = null; NotifyStopRunState = null; + Iteration = null; } /// Building block API: Prepares the provided for execution. diff --git a/Terminal.Gui/App/ApplicationImpl.cs b/Terminal.Gui/App/ApplicationImpl.cs index 007af49ae..decbfe5d8 100644 --- a/Terminal.Gui/App/ApplicationImpl.cs +++ b/Terminal.Gui/App/ApplicationImpl.cs @@ -633,6 +633,11 @@ public class ApplicationImpl : IApplication _cachedRunStateToplevel = null; _mainThreadId = -1; + + // These static properties need to be reset + Application.EndAfterFirstIteration = false; + Application.ClearScreenNextIteration = false; + Application.ClearForceFakeConsole (); // Driver stuff if (_driver is { }) @@ -664,6 +669,9 @@ public class ApplicationImpl : IApplication _navigation = null; + // Reset SupportedCultures so it's re-cached on next access + _supportedCultures = null; + // Reset synchronization context to allow the user to run async/await, // as the main loop has been ended, the synchronization context from // gui.cs does no longer process any callbacks. See #1084 for more details: