Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -163,10 +163,9 @@ public static Task<int> GetCursorTopAsync(CancellationToken cancellationToken) =
s_consoleProxy.GetCursorTopAsync(cancellationToken);

/// <summary>
/// On Unix platforms this method is sent to PSReadLine as a work around for issues
/// with the System.Console implementation for that platform. Functionally it is the
/// same as System.Console.ReadKey, with the exception that it will not lock the
/// standard input stream.
/// This method is sent to PSReadLine as a workaround for issues with the System.Console
/// implementation. Functionally it is the same as System.Console.ReadKey,
/// with the exception that it will not lock the standard input stream.
/// </summary>
/// <param name="intercept">
/// Determines whether to display the pressed key in the console window.
Expand All @@ -181,11 +180,11 @@ public static Task<int> GetCursorTopAsync(CancellationToken cancellationToken) =
/// in a bitwise combination of ConsoleModifiers values, whether one or more Shift, Alt,
/// or Ctrl modifier keys was pressed simultaneously with the console key.
/// </returns>
internal static ConsoleKeyInfo UnixReadKey(bool intercept, CancellationToken cancellationToken)
internal static ConsoleKeyInfo SafeReadKey(bool intercept, CancellationToken cancellationToken)
{
try
{
return ((UnixConsoleOperations)s_consoleProxy).ReadKey(intercept, cancellationToken);
return s_consoleProxy.ReadKey(intercept, cancellationToken);
}
catch (OperationCanceledException)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,13 +68,9 @@ internal PSReadLinePromptContext(
_consoleReadLine = new ConsoleReadLine(powerShellContext);
_readLineProxy = readLineProxy;

if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
{
return;
}

_readLineProxy.OverrideReadKey(
intercept => ConsoleProxy.UnixReadKey(
intercept => ConsoleProxy.SafeReadKey(
intercept,
_readLineCancellationSource.Token));
}
Expand Down