Skip to content

Commit 8eb3343

Browse files
committed
Trigger debugger change notification when a variable is set.
1 parent fac10e8 commit 8eb3343

File tree

3 files changed

+13
-4
lines changed

3 files changed

+13
-4
lines changed

Library/Scripting/Debugger/ScriptDebugContext.cs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ namespace BlocklyNet.Scripting.Debugger;
77
/// <summary>
88
/// Describes the current debug context.
99
/// </summary>
10-
public class ScriptDebugContext(string scriptId, Block block, ScriptDebuggerStopReason reason, Context context) : IScriptPosition
10+
public class ScriptDebugContext(string scriptId, Block block, ScriptDebuggerStopReason reason, Context context, ScriptDebugger debugger) : IScriptPosition
1111
{
1212
/// <summary>
1313
/// Current position.
@@ -42,7 +42,7 @@ public List<ScriptDebugVariableScope> GetVariables()
4242
{
4343
List<ScriptDebugVariableScope> list = [];
4444

45-
list.AddRange(GetVariables(Context));
45+
list.AddRange(GetVariables(Context, debugger));
4646

4747
return list;
4848
}
@@ -51,8 +51,9 @@ public List<ScriptDebugVariableScope> GetVariables()
5151
/// Get variables of a context.
5252
/// </summary>
5353
/// <param name="context">Context to inspect.</param>
54+
/// <param name="debugger">Corresponding script debugger.</param>
5455
/// <returns>List of variables.</returns>
55-
private static List<ScriptDebugVariableScope> GetVariables(Context context)
56+
private static List<ScriptDebugVariableScope> GetVariables(Context context, ScriptDebugger debugger)
5657
{
5758
List<ScriptDebugVariableScope> list = [];
5859

@@ -61,6 +62,7 @@ private static List<ScriptDebugVariableScope> GetVariables(Context context)
6162
list.Add(new()
6263
{
6364
Context = current,
65+
Debugger = debugger,
6466
Procedure = current is ProcedureContext procedure ? procedure.Name : null,
6567
ScriptId = script.Request.ScriptId,
6668
Variables = [

Library/Scripting/Debugger/ScriptDebugVariableScope.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,12 @@ public class ScriptDebugVariableScope
1919
[JsonIgnore]
2020
internal Context? Context { get; set; }
2121

22+
/// <summary>
23+
/// Debugger associated with this scope.
24+
/// </summary>
25+
[JsonIgnore]
26+
internal ScriptDebugger? Debugger { get; set; }
27+
2228
/// <summary>
2329
/// Corresponding script.
2430
/// </summary>
@@ -70,5 +76,6 @@ public void SetVariable(string name, string jsonValue)
7076
}
7177
}
7278

79+
Debugger?.SomethingChanged();
7380
}
7481
}

Library/Scripting/Debugger/ScriptDebugger.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,7 @@ private async Task<T> RunAsync<T>(Block block, Context context, ScriptDebuggerSt
219219
using (_sync.Wait())
220220
{
221221
/* Simplify overloads by providing some execution context. */
222-
_context = new(script.Request.ScriptId, block, reason, context);
222+
_context = new(script.Request.ScriptId, block, reason, context, this);
223223

224224
SomethingChanged();
225225

0 commit comments

Comments
 (0)