diff --git a/src/PowerShellEditorServices/Console/ConsoleReadLine.cs b/src/PowerShellEditorServices/Console/ConsoleReadLine.cs index d2e77c332..a277f9bf3 100644 --- a/src/PowerShellEditorServices/Console/ConsoleReadLine.cs +++ b/src/PowerShellEditorServices/Console/ConsoleReadLine.cs @@ -487,6 +487,19 @@ private async Task ReadKeyAsync(CancellationToken cancellationTo } else { + // Check to see if a key is available. + // If not check for cancellation requested. + while (!Console.KeyAvailable) + { + if (cancellationToken.IsCancellationRequested) + { + //this.bufferedKey = keyInfo; + throw new TaskCanceledException(); + } + + Thread.Sleep(100); + } + keyInfo = Console.ReadKey(true); if (cancellationToken.IsCancellationRequested)