diff --git a/ConsoleMenu/ConsoleMenu.cs b/ConsoleMenu/ConsoleMenu.cs index c193604..0334266 100644 --- a/ConsoleMenu/ConsoleMenu.cs +++ b/ConsoleMenu/ConsoleMenu.cs @@ -19,6 +19,7 @@ public class ConsoleMenu : IEnumerable private readonly CloseTrigger closeTrigger; private MenuConfig config = new MenuConfig(); private ConsoleMenu? parent = null; + private bool isShown = false; /// /// Initializes a new instance of the class. @@ -283,12 +284,7 @@ public ConsoleMenu Configure(MenuConfig config) /// public void Show() { - new ConsoleMenuDisplay( - this.menuItems, - this.Console, - new List(this.Titles), - this.config, - this.closeTrigger).ShowAsync(CancellationToken.None).GetAwaiter().GetResult(); + ShowAsync(CancellationToken.None).GetAwaiter().GetResult(); } /// @@ -296,6 +292,13 @@ public void Show() /// public async Task ShowAsync(CancellationToken cancellationToken = default) { + if (isShown) + { + this.menuItems.UnsetSelectedIndex(); + } + + isShown = true; + await new ConsoleMenuDisplay( this.menuItems, this.Console, diff --git a/ConsoleMenu/ConsoleMenu.csproj b/ConsoleMenu/ConsoleMenu.csproj index b7e33d8..7007258 100644 --- a/ConsoleMenu/ConsoleMenu.csproj +++ b/ConsoleMenu/ConsoleMenu.csproj @@ -6,10 +6,10 @@ lechu445 ConsoleMenu-simple A simple, highly customizable, DOS-like console menu - - added async API + - Fix Show already active menu causing StackOverflow (#16) https://github.com/lechu445/ConsoleMenu true - 2.6.0 + 2.6.1 https://github.com/lechu445/ConsoleMenu console, menu, simple LICENSE.txt diff --git a/ConsoleMenuSampleApp/ConsoleMenuSampleApp.csproj b/ConsoleMenuSampleApp/ConsoleMenuSampleApp.csproj index b66a0ae..1993cc6 100644 --- a/ConsoleMenuSampleApp/ConsoleMenuSampleApp.csproj +++ b/ConsoleMenuSampleApp/ConsoleMenuSampleApp.csproj @@ -2,7 +2,7 @@ Exe - net5.0 + net6.0 diff --git a/ConsoleMenuTests/ConsoleMenuTests.csproj b/ConsoleMenuTests/ConsoleMenuTests.csproj index 641c347..b115c46 100644 --- a/ConsoleMenuTests/ConsoleMenuTests.csproj +++ b/ConsoleMenuTests/ConsoleMenuTests.csproj @@ -1,16 +1,16 @@  - net5.0 + net6.0 false enable - - - + + + all runtime; build; native; contentfiles; analyzers; buildtransitive diff --git a/ConsoleMenuTests/TestHelpers/AssertHelper.cs b/ConsoleMenuTests/TestHelpers/AssertHelper.cs index 67f4bd0..60d00b1 100644 --- a/ConsoleMenuTests/TestHelpers/AssertHelper.cs +++ b/ConsoleMenuTests/TestHelpers/AssertHelper.cs @@ -12,7 +12,7 @@ public static void Equal(string expected, string actual) } catch (Xunit.Sdk.EqualException ex) { - throw new Xunit.Sdk.AssertActualExpectedException(expected, actual, "Expected was not equal to actual", "Expected", "Actual", ex); + throw new Xunit.Sdk.XunitException("Expected was not equal to actual", ex); } } }