Skip to content

Commit 8485855

Browse files
authored
Make PSReadLine script hidden from debugger (#3629)
1 parent 465da62 commit 8485855

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

PSReadLine/PSReadLine.psm1

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
function PSConsoleHostReadLine
22
{
3+
[System.Diagnostics.DebuggerHidden()]
4+
param()
5+
36
## Get the execution status of the last accepted user input.
47
## This needs to be done as the first thing because any script run will flush $?.
58
$lastRunStatus = $?

PSReadLine/ReadLine.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,7 @@ internal static PSKeyInfo ReadKey()
238238
if (ps == null)
239239
{
240240
ps = System.Management.Automation.PowerShell.Create(RunspaceMode.CurrentRunspace);
241-
ps.AddScript("0", useLocalScope: true);
241+
ps.AddScript("[System.Diagnostics.DebuggerHidden()]param() 0", useLocalScope: true);
242242
}
243243

244244
// To detect output during possible event processing, see if the cursor moved
@@ -674,7 +674,7 @@ private PSConsoleReadLine()
674674
{
675675
try
676676
{
677-
var results = ps.AddScript("$Host", useLocalScope: true).Invoke<PSHost>();
677+
var results = ps.AddScript("[System.Diagnostics.DebuggerHidden()]param() $Host", useLocalScope: true).Invoke<PSHost>();
678678
PSHost host = results.Count == 1 ? results[0] : null;
679679
hostName = host?.Name;
680680
}

0 commit comments

Comments
 (0)