File tree 3 files changed +33
-2
lines changed
src/PowerShellEditorServices/Session
3 files changed +33
-2
lines changed Original file line number Diff line number Diff line change @@ -33,8 +33,10 @@ public IEnumerable<TResult> ExecuteCommandInDebugger<TResult>(
33
33
{
34
34
IEnumerable < TResult > executionResult = null ;
35
35
36
- using ( var nestedPipeline = currentRunspace . CreateNestedPipeline ( ) )
36
+ string historyString = psCommand . Commands [ 0 ] . CommandText ;
37
+ using ( var nestedPipeline = currentRunspace . CreateNestedPipeline ( historyString , sendOutputToHost ) )
37
38
{
39
+ nestedPipeline . Commands . Clear ( ) ;
38
40
foreach ( var command in psCommand . Commands )
39
41
{
40
42
nestedPipeline . Commands . Add ( command ) ;
Original file line number Diff line number Diff line change @@ -13,6 +13,15 @@ namespace Microsoft.PowerShell.EditorServices.Session
13
13
{
14
14
internal class PowerShell4Operations : IVersionSpecificOperations
15
15
{
16
+ private static SortedSet < string > s_noHistoryCommandNames = new SortedSet < string > ( StringComparer . OrdinalIgnoreCase )
17
+ {
18
+ "prompt" ,
19
+ "Set-PSDebuggerAction" ,
20
+ "Get-PSDebuggerStopArgs" ,
21
+ "Set-PSDebugMode" ,
22
+ "TabExpansion2"
23
+ } ;
24
+
16
25
public void ConfigureDebugger ( Runspace runspace )
17
26
{
18
27
#if ! PowerShellv3
@@ -54,6 +63,24 @@ public IEnumerable<TResult> ExecuteCommandInDebugger<TResult>(
54
63
} ;
55
64
}
56
65
66
+ // There's no way to tell the debugger not to add the command to history. It does however,
67
+ // check if the first command is in a static list of commands that shouldn't be added
68
+ // to history. We use that here to get around that limitation.
69
+ if ( ! sendOutputToHost && ! s_noHistoryCommandNames . Contains ( psCommand . Commands [ 0 ] . CommandText ) )
70
+ {
71
+ var newCommand = new PSCommand ( )
72
+ . AddCommand ( "prompt" )
73
+ . AddCommand ( "Microsoft.PowerShell.Core\\ Out-Null" )
74
+ . AddStatement ( ) ;
75
+
76
+ foreach ( Command command in psCommand . Commands )
77
+ {
78
+ newCommand . AddCommand ( command ) ;
79
+ }
80
+
81
+ psCommand = newCommand ;
82
+ }
83
+
57
84
DebuggerCommandResults commandResults =
58
85
currentRunspace . Debugger . ProcessCommand (
59
86
psCommand ,
Original file line number Diff line number Diff line change @@ -1490,10 +1490,12 @@ private SessionDetails GetSessionDetailsInRunspace(Runspace runspace)
1490
1490
{
1491
1491
powerShell . Runspace = runspace ;
1492
1492
powerShell . Commands = command ;
1493
+ var invocationSettings = new PSInvocationSettings ( ) ;
1494
+ invocationSettings . AddToHistory = false ;
1493
1495
1494
1496
return
1495
1497
powerShell
1496
- . Invoke ( )
1498
+ . Invoke ( null , invocationSettings )
1497
1499
. FirstOrDefault ( ) ;
1498
1500
}
1499
1501
} ) ;
You can’t perform that action at this time.
0 commit comments