Skip to content

Commit d4ec378

Browse files
committed
Check the current runspace for debug API support
1 parent aaf27f7 commit d4ec378

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

src/PowerShellEditorServices/Services/DebugAdapter/BreakpointService.cs

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ namespace Microsoft.PowerShell.EditorServices.Services
1818
{
1919
internal class BreakpointService
2020
{
21+
private static readonly Version s_minimumBreakpointApiVersion = new Version(7, 0, 0, 0);
22+
2123
private readonly ILogger<BreakpointService> _logger;
2224
private readonly PowerShellExecutionService _executionService;
2325
private readonly InternalHost _editorServicesHost;
@@ -44,7 +46,7 @@ public BreakpointService(
4446

4547
public async Task<List<Breakpoint>> GetBreakpointsAsync()
4648
{
47-
if (BreakpointApiUtils.SupportsBreakpointApis)
49+
if (_editorServicesHost.CurrentRunspace.PowerShellVersionDetails.Version >= s_minimumBreakpointApiVersion)
4850
{
4951
return BreakpointApiUtils.GetBreakpoints(
5052
_editorServicesHost.Runspace.Debugger,
@@ -60,7 +62,7 @@ public async Task<List<Breakpoint>> GetBreakpointsAsync()
6062

6163
public async Task<IEnumerable<BreakpointDetails>> SetBreakpointsAsync(string escapedScriptPath, IEnumerable<BreakpointDetails> breakpoints)
6264
{
63-
if (BreakpointApiUtils.SupportsBreakpointApis)
65+
if (_editorServicesHost.CurrentRunspace.PowerShellVersionDetails.Version >= s_minimumBreakpointApiVersion)
6466
{
6567
foreach (BreakpointDetails breakpointDetails in breakpoints)
6668
{
@@ -150,7 +152,7 @@ public async Task<IEnumerable<BreakpointDetails>> SetBreakpointsAsync(string esc
150152

151153
public async Task<IEnumerable<CommandBreakpointDetails>> SetCommandBreakpoints(IEnumerable<CommandBreakpointDetails> breakpoints)
152154
{
153-
if (BreakpointApiUtils.SupportsBreakpointApis)
155+
if (_editorServicesHost.CurrentRunspace.PowerShellVersionDetails.Version >= s_minimumBreakpointApiVersion)
154156
{
155157
foreach (CommandBreakpointDetails commandBreakpointDetails in breakpoints)
156158
{
@@ -232,7 +234,7 @@ public async Task RemoveAllBreakpointsAsync(string scriptPath = null)
232234
{
233235
try
234236
{
235-
if (BreakpointApiUtils.SupportsBreakpointApis)
237+
if (_editorServicesHost.CurrentRunspace.PowerShellVersionDetails.Version >= s_minimumBreakpointApiVersion)
236238
{
237239
foreach (Breakpoint breakpoint in BreakpointApiUtils.GetBreakpoints(
238240
_editorServicesHost.Runspace.Debugger,
@@ -272,7 +274,7 @@ public async Task RemoveAllBreakpointsAsync(string scriptPath = null)
272274

273275
public async Task RemoveBreakpointsAsync(IEnumerable<Breakpoint> breakpoints)
274276
{
275-
if (BreakpointApiUtils.SupportsBreakpointApis)
277+
if (_editorServicesHost.CurrentRunspace.PowerShellVersionDetails.Version >= s_minimumBreakpointApiVersion)
276278
{
277279
foreach (Breakpoint breakpoint in breakpoints)
278280
{

0 commit comments

Comments
 (0)