From 5d4883f709a1adb3c502e3f1ed54c4dc17639e41 Mon Sep 17 00:00:00 2001 From: Tyler Leonhardt Date: Thu, 24 Oct 2019 12:01:44 -0700 Subject: [PATCH] initial attempt --- .../PowerShellContext/Console/ConsoleProxy.cs | 11 +++++------ .../Session/PSReadLinePromptContext.cs | 6 +----- 2 files changed, 6 insertions(+), 11 deletions(-) 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)); }