Add step out to script debugger

This commit is contained in:
TsFreddie 2024-10-03 15:54:43 +08:00
parent 2e14492879
commit bfdabe2c1c
No known key found for this signature in database
GPG key ID: 3054B1FC80F9AF6F
6 changed files with 29 additions and 0 deletions

View file

@ -224,6 +224,10 @@ void LocalDebugger::debug(bool p_can_continue, bool p_is_error_breakpoint) {
script_debugger->set_depth(0);
script_debugger->set_lines_left(1);
break;
} else if (line == "o" || line == "out") {
script_debugger->set_depth(1);
script_debugger->set_lines_left(1);
break;
} else if (line == "fin" || line == "finish") {
String current_function = script_lang->debug_get_stack_level_function(0);

View file

@ -462,6 +462,11 @@ void RemoteDebugger::debug(bool p_can_continue, bool p_is_error_breakpoint) {
script_debugger->set_lines_left(1);
break;
} else if (command == "out") {
script_debugger->set_depth(1);
script_debugger->set_lines_left(1);
break;
} else if (command == "continue") {
script_debugger->set_depth(-1);
script_debugger->set_lines_left(-1);

View file

@ -105,6 +105,13 @@ void ScriptEditorDebugger::debug_skip_breakpoints() {
_put_msg("set_skip_breakpoints", msg, debugging_thread_id != Thread::UNASSIGNED_ID ? debugging_thread_id : Thread::MAIN_ID);
}
void ScriptEditorDebugger::debug_out() {
ERR_FAIL_COND(!is_breaked());
_put_msg("out", Array(), debugging_thread_id);
_clear_execution();
}
void ScriptEditorDebugger::debug_next() {
ERR_FAIL_COND(!is_breaked());
@ -867,6 +874,7 @@ void ScriptEditorDebugger::_notification(int p_what) {
copy->set_icon(get_editor_theme_icon(SNAME("ActionCopy")));
step->set_icon(get_editor_theme_icon(SNAME("DebugStep")));
next->set_icon(get_editor_theme_icon(SNAME("DebugNext")));
out->set_icon(get_editor_theme_icon(SNAME("DebugOut")));
dobreak->set_icon(get_editor_theme_icon(SNAME("Pause")));
docontinue->set_icon(get_editor_theme_icon(SNAME("DebugContinue")));
vmem_refresh->set_icon(get_editor_theme_icon(SNAME("Reload")));
@ -1032,6 +1040,7 @@ void ScriptEditorDebugger::_update_buttons_state() {
vmem_refresh->set_disabled(!active);
step->set_disabled(!active || !is_breaked() || !is_debuggable());
next->set_disabled(!active || !is_breaked() || !is_debuggable());
out->set_disabled(!active || !is_breaked() || !is_debuggable());
copy->set_disabled(!active || !is_breaked());
docontinue->set_disabled(!active || !is_breaked());
dobreak->set_disabled(!active || is_breaked());
@ -1863,6 +1872,13 @@ ScriptEditorDebugger::ScriptEditorDebugger() {
next->set_shortcut(ED_GET_SHORTCUT("debugger/step_over"));
next->connect(SceneStringName(pressed), callable_mp(this, &ScriptEditorDebugger::debug_next));
out = memnew(Button);
out->set_theme_type_variation("FlatButton");
hbc->add_child(out);
out->set_tooltip_text(TTR("Step Out"));
out->set_shortcut(ED_GET_SHORTCUT("debugger/step_out"));
out->connect(SceneStringName(pressed), callable_mp(this, &ScriptEditorDebugger::debug_out));
hbc->add_child(memnew(VSeparator));
dobreak = memnew(Button);

View file

@ -125,6 +125,7 @@ private:
Button *copy = nullptr;
Button *step = nullptr;
Button *next = nullptr;
Button *out = nullptr;
Button *dobreak = nullptr;
Button *docontinue = nullptr;
// Reference to "Remote" tab in scene tree. Needed by _live_edit_set and buttons state.
@ -260,6 +261,7 @@ public:
void debug_skip_breakpoints();
void debug_copy();
void debug_out();
void debug_next();
void debug_step();
void debug_break();

View file

@ -0,0 +1 @@
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16"><path fill="#ff5f5f" d="M3 15V5H1l1.5-2L4 1l1.5 2L7 5H5v10z"/><path fill="#e0e0e0" d="M7 1v2h8V1Zm2 4v2h6V5Zm0 4v2h6V9Zm-2 4v2h8v-2z"/></svg>

After

Width:  |  Height:  |  Size: 204 B

View file

@ -48,6 +48,7 @@ DebuggerEditorPlugin::DebuggerEditorPlugin(PopupMenu *p_debug_menu) {
ED_SHORTCUT("debugger/step_into", TTR("Step Into"), Key::F11);
ED_SHORTCUT("debugger/step_over", TTR("Step Over"), Key::F10);
ED_SHORTCUT("debugger/step_out", TTR("Step Out"), KeyModifierMask::SHIFT | Key::F11);
ED_SHORTCUT("debugger/break", TTR("Break"));
ED_SHORTCUT("debugger/continue", TTR("Continue"), Key::F12);
ED_SHORTCUT("debugger/debug_with_external_editor", TTR("Debug with External Editor"));