Skip to content

Commit

Permalink
Added enhanced checking of interactive environments (#231)
Browse files Browse the repository at this point in the history
  • Loading branch information
shibayan authored Aug 26, 2022
1 parent 1013696 commit 5331396
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion Sharprompt/Drivers/DefaultConsoleDriver.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System;
using System.IO;
using System.Runtime.InteropServices;

using Sharprompt.Internal;
Expand Down Expand Up @@ -32,7 +33,14 @@ public DefaultConsoleDriver()
{
_previousTreatControlCAsInput = Console.TreatControlCAsInput;

Console.TreatControlCAsInput = true;
try
{
Console.TreatControlCAsInput = true;
}
catch (IOException)
{
throw new InvalidOperationException(Resource.Message_NotSupportedEnvironment);
}
}

private readonly bool _previousTreatControlCAsInput;
Expand Down

0 comments on commit 5331396

Please sign in to comment.