File tree Expand file tree Collapse file tree 3 files changed +30
-1
lines changed
PowerShellEditorServices.Protocol
PowerShellEditorServices/Debugging Expand file tree Collapse file tree 3 files changed +30
-1
lines changed Original file line number Diff line number Diff line change @@ -22,6 +22,12 @@ public class LaunchRequestArguments
22
22
/// </summary>
23
23
public string Program { get ; set ; }
24
24
25
+ /// <summary>
26
+ /// Gets or sets a boolean value that indicates whether the script should be
27
+ /// run with (false) or without (true) debugging support.
28
+ /// </summary>
29
+ public bool NoDebug { get ; set ; }
30
+
25
31
/// <summary>
26
32
/// Gets or sets a boolean value that determines whether to automatically stop
27
33
/// target after launch. If not specified, target does not stop.
Original file line number Diff line number Diff line change @@ -23,6 +23,7 @@ public class DebugAdapter : DebugAdapterBase
23
23
private OutputDebouncer outputDebouncer ;
24
24
private bool isConfigurationDoneRequestComplete ;
25
25
private bool isLaunchRequestComplete ;
26
+ private bool noDebug ;
26
27
private string scriptPathToLaunch ;
27
28
private string arguments ;
28
29
@@ -72,6 +73,13 @@ protected override void Initialize()
72
73
73
74
protected Task LaunchScript ( RequestContext < object > requestContext )
74
75
{
76
+ // If this is a run without debugging session, disable all breakpoints.
77
+ if ( this . noDebug )
78
+ {
79
+ Task diableBreakpoints = this . editorSession . DebugService . DisableAllBreakpoints ( ) ;
80
+ Task . WhenAll ( diableBreakpoints ) ;
81
+ }
82
+
75
83
return editorSession . PowerShellContext
76
84
. ExecuteScriptAtPath ( this . scriptPathToLaunch , this . arguments )
77
85
. ContinueWith (
@@ -158,6 +166,7 @@ protected async Task HandleLaunchRequest(
158
166
// If the launch request comes first, then stash the launch
159
167
// params so that the subsequent configurationDone request handler
160
168
// can launch the script.
169
+ this . noDebug = launchParams . NoDebug ;
161
170
this . scriptPathToLaunch = launchParams . Program ;
162
171
this . arguments = arguments ;
163
172
Original file line number Diff line number Diff line change @@ -57,6 +57,20 @@ public DebugService(PowerShellContext powerShellContext)
57
57
58
58
#region Public Methods
59
59
60
+ /// <summary>
61
+ /// Disables all breakpoints in the runspace.
62
+ /// </summary>
63
+ /// <returns></returns>
64
+ public async Task DisableAllBreakpoints ( )
65
+ {
66
+ var psCommand = new PSCommand ( ) ;
67
+
68
+ psCommand . AddCommand ( @"Microsoft.PowerShell.Utility\Get-PSBreakpoint" ) ;
69
+ psCommand . AddCommand ( @"Microsoft.PowerShell.Utility\Disable-PSBreakpoint" ) ;
70
+
71
+ await this . powerShellContext . ExecuteCommand ( psCommand ) ;
72
+ }
73
+
60
74
/// <summary>
61
75
/// Sets the list of line breakpoints for the current debugging session.
62
76
/// </summary>
@@ -86,7 +100,7 @@ public async Task<BreakpointDetails[]> SetLineBreakpoints(
86
100
foreach ( BreakpointDetails breakpoint in breakpoints )
87
101
{
88
102
PSCommand psCommand = new PSCommand ( ) ;
89
- psCommand . AddCommand ( " Set-PSBreakpoint") ;
103
+ psCommand . AddCommand ( @"Microsoft.PowerShell.Utility\ Set-PSBreakpoint") ;
90
104
psCommand . AddParameter ( "Script" , escapedScriptPath ) ;
91
105
psCommand . AddParameter ( "Line" , breakpoint . LineNumber ) ;
92
106
You can’t perform that action at this time.
0 commit comments