Add a private field to indicate if PSReadLine is initialized and ready (#4706)

This commit is contained in:
Dongbo Wang
2025-04-16 10:09:46 -07:00
committed by GitHub
parent 4a2bf98ac4
commit b926959840
+5
View File
@@ -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,