Skip to content

Commit 1eab605

Browse files
committed
Add cancellation token support
1 parent 4617938 commit 1eab605

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

PSReadLine/ReadLine.cs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,9 @@ public partial class PSConsoleReadLine : IPSConsoleReadLineMockableMethods
4444

4545
private static readonly CancellationToken _defaultCancellationToken = new CancellationTokenSource().Token;
4646

47-
private static Action _handleIdleOverride;
47+
// This exists for PowerShell Editor Services (the backend of the PowerShell VSCode extension)
48+
// so that it can call PSReadLine from a delegate and not hit nested pipeline issues
49+
private static Action<CancellationToken> _handleIdleOverride;
4850

4951
private bool _delayedOneTimeInitCompleted;
5052

@@ -203,9 +205,9 @@ internal static PSKeyInfo ReadKey()
203205
if (handleId != WaitHandle.WaitTimeout && handleId != EventProcessingRequested)
204206
break;
205207

206-
if (_handleIdleOverride != null)
208+
if (_handleIdleOverride is not null)
207209
{
208-
_handleIdleOverride();
210+
_handleIdleOverride(_singleton._cancelReadCancellationToken);
209211
continue;
210212
}
211213

0 commit comments

Comments
 (0)