From b9269598407c6de15dc0ed7693184ce899792708 Mon Sep 17 00:00:00 2001 From: Dongbo Wang Date: Wed, 16 Apr 2025 10:09:46 -0700 Subject: [PATCH] Add a private field to indicate if PSReadLine is initialized and ready (#4706) --- PSReadLine/ReadLine.cs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/PSReadLine/ReadLine.cs b/PSReadLine/ReadLine.cs index 02a0455..677025a 100644 --- a/PSReadLine/ReadLine.cs +++ b/PSReadLine/ReadLine.cs @@ -43,6 +43,8 @@ namespace Microsoft.PowerShell #pragma warning restore CS0649 private bool _delayedOneTimeInitCompleted; + // This is used by AIShell to check if PSReadLine is initialized and ready to render. + private bool _readLineReady; private IPSConsoleReadLineMockableMethods _mockableMethods; private IConsole _console; @@ -400,6 +402,7 @@ namespace Microsoft.PowerShell _singleton.Initialize(runspace, engineIntrinsics); } + _singleton._readLineReady = true; _singleton._cancelReadCancellationToken = cancellationToken; return _singleton.InputLoop(); } @@ -472,6 +475,8 @@ namespace Microsoft.PowerShell } finally { + _singleton._readLineReady = false; + try { // If we are closing, restoring the old console settings isn't needed,