Skip to content

Commit

Permalink
Remove PSES force event handling hook
Browse files Browse the repository at this point in the history
  • Loading branch information
rjmholt committed Jul 22, 2020
1 parent 882dfa8 commit ef8a1c6
Showing 1 changed file with 1 addition and 17 deletions.
18 changes: 1 addition & 17 deletions PSReadLine/ReadLine.cs
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,6 @@ internal static PSKeyInfo ReadKey()
// - a key is pressed
// - the console is exiting
// - 300ms - to process events if we're idle
// - processing of events is requested externally
// - ReadLine cancellation is requested externally
handleId = WaitHandle.WaitAny(_singleton._requestKeyWaitHandles, 300);
if (handleId != WaitHandle.WaitTimeout && handleId != EventProcessingRequested)
Expand Down Expand Up @@ -650,10 +649,6 @@ private PSConsoleReadLine()
_savedCurrentLine = new HistoryItem();
_queuedKeys = new Queue<PSKeyInfo>();

// Initialize this event handler early because it could be used by PowerShell
// Editor Services before 'DelayedOneTimeInitialize' runs.
_forceEventWaitHandle = new AutoResetEvent(false);

string hostName = null;
// This works mostly by luck - we're not doing anything to guarantee the constructor for our
// singleton is called on a thread with a runspace, but it is happening by coincidence.
Expand Down Expand Up @@ -838,7 +833,7 @@ private void DelayedOneTimeInitialize()
_singleton._readKeyWaitHandle = new AutoResetEvent(false);
_singleton._keyReadWaitHandle = new AutoResetEvent(false);
_singleton._closingWaitHandle = new ManualResetEvent(false);
_singleton._requestKeyWaitHandles = new WaitHandle[] {_singleton._keyReadWaitHandle, _singleton._closingWaitHandle, _defaultCancellationToken.WaitHandle, _singleton._forceEventWaitHandle};
_singleton._requestKeyWaitHandles = new WaitHandle[] {_singleton._keyReadWaitHandle, _singleton._closingWaitHandle, _defaultCancellationToken.WaitHandle};
_singleton._threadProcWaitHandles = new WaitHandle[] {_singleton._readKeyWaitHandle, _singleton._closingWaitHandle};

// This is for a "being hosted in an alternate appdomain scenario" (the
Expand All @@ -858,17 +853,6 @@ private void DelayedOneTimeInitialize()
_singleton._readKeyThread.Start();
}

/// <summary>
/// Used by PowerShellEditorServices to force immediate
/// event handling during the <see cref="PSConsoleReadLine.ReadKey" />
/// method. This is not a public API, but it is part of a private contract
/// with that project.
/// </summary>
private static void ForcePSEventHandling()
{
_singleton._forceEventWaitHandle.Set();
}

private static void Chord(ConsoleKeyInfo? key = null, object arg = null)
{
if (!key.HasValue)
Expand Down

0 comments on commit ef8a1c6

Please sign in to comment.