diff --git a/src/PowerShellEditorServices/Services/PowerShellContext/Console/ConsoleProxy.cs b/src/PowerShellEditorServices/Services/PowerShellContext/Console/ConsoleProxy.cs index cda8997fe..4c2f92015 100644 --- a/src/PowerShellEditorServices/Services/PowerShellContext/Console/ConsoleProxy.cs +++ b/src/PowerShellEditorServices/Services/PowerShellContext/Console/ConsoleProxy.cs @@ -163,10 +163,9 @@ public static Task GetCursorTopAsync(CancellationToken cancellationToken) = s_consoleProxy.GetCursorTopAsync(cancellationToken); /// - /// 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. /// /// /// Determines whether to display the pressed key in the console window. @@ -181,11 +180,11 @@ public static Task 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. /// - 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) { diff --git a/src/PowerShellEditorServices/Services/PowerShellContext/Session/PSReadLinePromptContext.cs b/src/PowerShellEditorServices/Services/PowerShellContext/Session/PSReadLinePromptContext.cs index 26b3cc5a7..f03e17f07 100644 --- a/src/PowerShellEditorServices/Services/PowerShellContext/Session/PSReadLinePromptContext.cs +++ b/src/PowerShellEditorServices/Services/PowerShellContext/Session/PSReadLinePromptContext.cs @@ -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)); }