Skip to content

Commit 882dfa8

Browse files
committed
Add private contract delegate for PSES to handle idle on readline
1 parent fd99806 commit 882dfa8

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

PSReadLine.build.ps1

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,10 @@ task LayoutModule BuildMainModule, {
130130
$binPath = "PSReadLine/bin/$Configuration/$Framework/publish"
131131
Copy-Item $binPath/Microsoft.PowerShell.PSReadLine2.dll $targetDir
132132

133+
if ($Configuration -eq 'Debug') {
134+
Copy-Item $binPath/*.pdb $targetDir
135+
}
136+
133137
if (Test-Path $binPath/System.Runtime.InteropServices.RuntimeInformation.dll)
134138
{
135139
Copy-Item $binPath/System.Runtime.InteropServices.RuntimeInformation.dll $targetDir

PSReadLine/ReadLine.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,8 @@ public partial class PSConsoleReadLine : IPSConsoleReadLineMockableMethods
4444

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

47+
private static Action _handleIdleOverride;
48+
4749
private bool _delayedOneTimeInitCompleted;
4850

4951
private IPSConsoleReadLineMockableMethods _mockableMethods;
@@ -201,6 +203,12 @@ internal static PSKeyInfo ReadKey()
201203
if (handleId != WaitHandle.WaitTimeout && handleId != EventProcessingRequested)
202204
break;
203205

206+
if (_handleIdleOverride != null)
207+
{
208+
_handleIdleOverride();
209+
continue;
210+
}
211+
204212
// If we timed out, check for event subscribers (which is just
205213
// a hint that there might be an event waiting to be processed.)
206214
var eventSubscribers = _singleton._engineIntrinsics?.Events.Subscribers;

0 commit comments

Comments
 (0)