diff --git a/PSReadLine/PSReadLine.psm1 b/PSReadLine/PSReadLine.psm1 index 74c27141..572aee80 100644 --- a/PSReadLine/PSReadLine.psm1 +++ b/PSReadLine/PSReadLine.psm1 @@ -1,5 +1,8 @@ function PSConsoleHostReadLine { + [System.Diagnostics.DebuggerHidden()] + param() + ## Get the execution status of the last accepted user input. ## This needs to be done as the first thing because any script run will flush $?. $lastRunStatus = $? diff --git a/PSReadLine/ReadLine.cs b/PSReadLine/ReadLine.cs index a6010bb9..33b65d06 100644 --- a/PSReadLine/ReadLine.cs +++ b/PSReadLine/ReadLine.cs @@ -238,7 +238,7 @@ internal static PSKeyInfo ReadKey() if (ps == null) { ps = System.Management.Automation.PowerShell.Create(RunspaceMode.CurrentRunspace); - ps.AddScript("0", useLocalScope: true); + ps.AddScript("[System.Diagnostics.DebuggerHidden()]param() 0", useLocalScope: true); } // To detect output during possible event processing, see if the cursor moved @@ -674,7 +674,7 @@ private PSConsoleReadLine() { try { - var results = ps.AddScript("$Host", useLocalScope: true).Invoke(); + var results = ps.AddScript("[System.Diagnostics.DebuggerHidden()]param() $Host", useLocalScope: true).Invoke(); PSHost host = results.Count == 1 ? results[0] : null; hostName = host?.Name; }