Skip to content
This repository was archived by the owner on Apr 5, 2024. It is now read-only.

Commit 6b2fbd3

Browse files
committed
Implemented conditional breakpoints.
1 parent c0ab7c7 commit 6b2fbd3

File tree

3 files changed

+24
-3
lines changed

3 files changed

+24
-3
lines changed

Changelog.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@ Git: https://github.com/Unity-Technologies/vscode-unity-debug
66
Changes
77
-------
88

9+
2.3.0
10+
=====
11+
- Added support for conditional breakpoints.
12+
913
2.2.0
1014
=====
1115
- Added support for setValue. This makes it possible to modify variables at runtime.

UnityDebug/UnityDebugSession.cs

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414
using VSCodeDebug;
1515
using MonoDevelop.Debugger.Soft.Unity;
1616
using MonoDevelop.Unity.Debugger;
17+
using Newtonsoft.Json.Linq;
18+
using Breakpoint = Mono.Debugging.Client.Breakpoint;
1719

1820
namespace UnityDebug
1921
{
@@ -177,7 +179,7 @@ public override void Initialize(Response response, dynamic args)
177179
supportsFunctionBreakpoints = false,
178180

179181
// This debug adapter doesn't support conditional breakpoints.
180-
supportsConditionalBreakpoints = false,
182+
supportsConditionalBreakpoints = true,
181183

182184
// This debug adapter does support a side effect free evaluate request for data hovers.
183185
supportsEvaluateForHovers = true,
@@ -490,10 +492,18 @@ public override void SetBreakpoints(Response response, dynamic args)
490492
}
491493

492494
var breakpoints = new List<VSCodeDebug.Breakpoint>();
493-
foreach (var l in clientLines) {
495+
foreach (var l in clientLines)
496+
{
494497
breakpoints.Add(new VSCodeDebug.Breakpoint(true, l));
495498
}
496499

500+
SourceBreakpoint[] breaks = getBreakpoints(args, "breakpoints");
501+
foreach (Breakpoint breakpoint in _session.Breakpoints)
502+
{
503+
var sourceBreakpoint = breaks.First(bp => bp.line == breakpoint.Line);
504+
breakpoint.ConditionExpression = sourceBreakpoint.condition;
505+
}
506+
497507
SendResponse(response, new SetBreakpointsResponseBody(breakpoints));
498508
}
499509

@@ -912,6 +922,13 @@ private static string getString(dynamic args, string property, string dflt = nul
912922
}
913923
return s;
914924
}
925+
926+
static SourceBreakpoint[] getBreakpoints(dynamic args, string property)
927+
{
928+
JArray jsonBreakpoints = args[property];
929+
var breakpoints = jsonBreakpoints.ToObject<SourceBreakpoint[]>();
930+
return breakpoints ?? new SourceBreakpoint[0];
931+
}
915932

916933
private void DebuggerKill()
917934
{

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "unity-debug",
33
"displayName": "Debugger for Unity",
4-
"version": "2.2.0",
4+
"version": "2.3.0",
55
"publisher": "Unity",
66
"description": "Unity debugger extension",
77
"engines": {

0 commit comments

Comments
 (0)