debugger step in, step out, continue

This commit is contained in:
Matt Parker
2025-12-12 19:05:43 +10:00
parent a855e52261
commit 29d101867f
6 changed files with 67 additions and 7 deletions

View File

@@ -52,7 +52,19 @@ public partial class CodeEditorPanel : MarginContainer
{
if (@event.IsActionPressed(InputStringNames.StepOver))
{
SendDebuggerStepOver();
SendDebuggerStepCommand(DebuggerStepAction.StepOver);
}
else if (@event.IsActionPressed(InputStringNames.DebuggerStepOut))
{
SendDebuggerStepCommand(DebuggerStepAction.StepOut);
}
else if (@event.IsActionPressed(InputStringNames.DebuggerStepIn))
{
SendDebuggerStepCommand(DebuggerStepAction.StepIn);
}
else if (@event.IsActionPressed(InputStringNames.DebuggerContinue))
{
SendDebuggerStepCommand(DebuggerStepAction.Continue);
}
}
@@ -142,7 +154,8 @@ public partial class CodeEditorPanel : MarginContainer
});
}
private void SendDebuggerStepOver()
private enum DebuggerStepAction { StepOver, StepIn, StepOut, Continue }
private void SendDebuggerStepCommand(DebuggerStepAction debuggerStepAction)
{
if (_debuggerExecutionStopInfo is null) return; // ie not currently stopped
var godotLine = _debuggerExecutionStopInfo.Line - 1;
@@ -153,7 +166,15 @@ public partial class CodeEditorPanel : MarginContainer
_debuggerExecutionStopInfo = null;
_ = Task.GodotRun(async () =>
{
await _runService.SendDebuggerStepOver(threadId);
var task = debuggerStepAction switch
{
DebuggerStepAction.StepOver => _runService.SendDebuggerStepOver(threadId),
DebuggerStepAction.StepIn => _runService.SendDebuggerStepInto(threadId),
DebuggerStepAction.StepOut => _runService.SendDebuggerStepOut(threadId),
DebuggerStepAction.Continue => _runService.SendDebuggerContinue(threadId),
_ => throw new ArgumentOutOfRangeException(nameof(debuggerStepAction), debuggerStepAction, null)
};
await task;
});
}
}

View File

@@ -7,6 +7,9 @@ public static class InputStringNames
public static readonly StringName RenameSymbol = nameof(RenameSymbol);
public static readonly StringName CodeFixes = nameof(CodeFixes);
public static readonly StringName StepOver = nameof(StepOver);
public static readonly StringName DebuggerStepIn = nameof(DebuggerStepIn);
public static readonly StringName DebuggerStepOut = nameof(DebuggerStepOut);
public static readonly StringName DebuggerContinue = nameof(DebuggerContinue);
public static readonly StringName FindInFiles = nameof(FindInFiles);
public static readonly StringName FindFiles = nameof(FindFiles);
public static readonly StringName SaveFile = nameof(SaveFile);

View File

@@ -73,6 +73,21 @@ RenameSymbol={
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":4194333,"key_label":0,"unicode":0,"location":0,"echo":false,"script":null)
]
}
DebuggerContinue={
"deadzone": 0.2,
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":4194336,"physical_keycode":0,"key_label":0,"unicode":0,"location":0,"echo":false,"script":null)
]
}
DebuggerStepIn={
"deadzone": 0.2,
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":4194342,"physical_keycode":0,"key_label":0,"unicode":0,"location":0,"echo":false,"script":null)
]
}
DebuggerStepOut={
"deadzone": 0.2,
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":true,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":4194342,"physical_keycode":0,"key_label":0,"unicode":0,"location":0,"echo":false,"script":null)
]
}
[rendering]