Skip to content

Commit

Permalink
Add private contract delegate for PSES to handle idle on readline
Browse files Browse the repository at this point in the history
  • Loading branch information
rjmholt committed Jun 25, 2020
1 parent fd99806 commit 882dfa8
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
4 changes: 4 additions & 0 deletions PSReadLine.build.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,10 @@ task LayoutModule BuildMainModule, {
$binPath = "PSReadLine/bin/$Configuration/$Framework/publish"
Copy-Item $binPath/Microsoft.PowerShell.PSReadLine2.dll $targetDir

if ($Configuration -eq 'Debug') {
Copy-Item $binPath/*.pdb $targetDir
}

if (Test-Path $binPath/System.Runtime.InteropServices.RuntimeInformation.dll)
{
Copy-Item $binPath/System.Runtime.InteropServices.RuntimeInformation.dll $targetDir
Expand Down
8 changes: 8 additions & 0 deletions PSReadLine/ReadLine.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ public partial class PSConsoleReadLine : IPSConsoleReadLineMockableMethods

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

private static Action _handleIdleOverride;

private bool _delayedOneTimeInitCompleted;

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

if (_handleIdleOverride != null)
{
_handleIdleOverride();
continue;
}

// If we timed out, check for event subscribers (which is just
// a hint that there might be an event waiting to be processed.)
var eventSubscribers = _singleton._engineIntrinsics?.Events.Subscribers;
Expand Down

0 comments on commit 882dfa8

Please sign in to comment.