From 35ddb58af63a56bad230fd92b9f2dc2f04b1e4a4 Mon Sep 17 00:00:00 2001 From: Tyler James Leonhardt Date: Thu, 14 May 2020 13:10:14 -0700 Subject: [PATCH 1/2] useLocalScope to true so that it works in CLM --- PSReadLine/ReadLine.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/PSReadLine/ReadLine.cs b/PSReadLine/ReadLine.cs index fe2c7167..9e2bf6ba 100644 --- a/PSReadLine/ReadLine.cs +++ b/PSReadLine/ReadLine.cs @@ -230,7 +230,7 @@ internal static PSKeyInfo ReadKey() if (ps == null) { ps = System.Management.Automation.PowerShell.Create(RunspaceMode.CurrentRunspace); - ps.AddScript("0"); + ps.AddScript("0", useLocalScope: true); } // To detect output during possible event processing, see if the cursor moved From f8746093ddab8e58580a646382456c34636285a2 Mon Sep 17 00:00:00 2001 From: Tyler James Leonhardt Date: Thu, 14 May 2020 15:18:18 -0700 Subject: [PATCH 2/2] also update another instance of AddScript --- PSReadLine/ReadLine.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/PSReadLine/ReadLine.cs b/PSReadLine/ReadLine.cs index 9e2bf6ba..b1fbbbea 100644 --- a/PSReadLine/ReadLine.cs +++ b/PSReadLine/ReadLine.cs @@ -653,7 +653,7 @@ private PSConsoleReadLine() { try { - var results = ps.AddScript("$Host").Invoke(); + var results = ps.AddScript("$Host", useLocalScope: true).Invoke(); PSHost host = results.Count == 1 ? results[0] : null; hostName = host?.Name; }