diff options
-rw-r--r-- | editor/plugins/script_editor_plugin.cpp | 24 | ||||
-rw-r--r-- | editor/plugins/script_editor_plugin.h | 1 | ||||
-rw-r--r-- | editor/plugins/script_text_editor.cpp | 2 | ||||
-rw-r--r-- | editor/script_editor_debugger.cpp | 21 | ||||
-rw-r--r-- | editor/script_editor_debugger.h | 7 | ||||
-rw-r--r-- | modules/gdnative/gdnative.h | 2 | ||||
-rw-r--r-- | modules/gdscript/gd_script.h | 1 | ||||
-rw-r--r-- | modules/visual_script/visual_script.h | 1 |
8 files changed, 49 insertions, 10 deletions
diff --git a/editor/plugins/script_editor_plugin.cpp b/editor/plugins/script_editor_plugin.cpp index f3941d6a16..0024870665 100644 --- a/editor/plugins/script_editor_plugin.cpp +++ b/editor/plugins/script_editor_plugin.cpp @@ -313,6 +313,13 @@ void ScriptEditor::_goto_script_line(REF p_script, int p_line) { editor->push_item(p_script.ptr()); + if (bool(EditorSettings::get_singleton()->get("text_editor/external/use_external_editor"))) { + + Ref<Script> script = p_script->cast_to<Script>(); + if (!script.is_null() && script->get_path().is_resource_file()) + edit(p_script, p_line, 0); + } + int selected = tab_container->get_current_tab(); if (selected < 0 || selected >= tab_container->get_child_count()) return; @@ -866,6 +873,11 @@ void ScriptEditor::_menu_option(int p_option) { debugger->set_hide_on_stop(visible); debug_menu->get_popup()->set_item_checked(debug_menu->get_popup()->get_item_index(DEBUG_SHOW_KEEP_OPEN), !visible); } break; + case DEBUG_WITH_EXTERNAL_EDITOR: { + bool debug_with_external_editor = !debug_menu->get_popup()->is_item_checked(debug_menu->get_popup()->get_item_index(DEBUG_WITH_EXTERNAL_EDITOR)); + debugger->set_debug_with_external_editor(debug_with_external_editor); + debug_menu->get_popup()->set_item_checked(debug_menu->get_popup()->get_item_index(DEBUG_WITH_EXTERNAL_EDITOR), debug_with_external_editor); + } } int selected = tab_container->get_current_tab(); @@ -1545,13 +1557,10 @@ bool ScriptEditor::edit(const Ref<Script> &p_script, int p_line, int p_col, bool bool open_dominant = EditorSettings::get_singleton()->get("text_editor/files/open_dominant_script_on_scene_change"); - Error err = p_script->get_language()->open_in_external_editor(p_script, p_line >= 0 ? p_line : 0, p_col); - if (err == OK) - return false; - if (err != ERR_UNAVAILABLE) - WARN_PRINT("Couldn't open in custom external text editor"); - - if (p_script->get_path().is_resource_file() && bool(EditorSettings::get_singleton()->get("text_editor/external/use_external_editor"))) { + if ((debugger->get_dump_stack_script() != p_script || debugger->get_debug_with_external_editor()) && + p_script->get_language()->open_in_external_editor(p_script, p_line >= 0 ? p_line : 0, p_col) == OK && + p_script->get_path().is_resource_file() && + bool(EditorSettings::get_singleton()->get("text_editor/external/use_external_editor"))) { String path = EditorSettings::get_singleton()->get("text_editor/external/exec_path"); String flags = EditorSettings::get_singleton()->get("text_editor/external/exec_flags"); @@ -2244,6 +2253,7 @@ ScriptEditor::ScriptEditor(EditorNode *p_editor) { debug_menu->get_popup()->add_separator(); //debug_menu->get_popup()->add_check_item("Show Debugger",DEBUG_SHOW); debug_menu->get_popup()->add_check_shortcut(ED_SHORTCUT("debugger/keep_debugger_open", TTR("Keep Debugger Open")), DEBUG_SHOW_KEEP_OPEN); + debug_menu->get_popup()->add_check_shortcut(ED_SHORTCUT("debugger/debug_with_exteral_editor", TTR("Debug with external editor")), DEBUG_WITH_EXTERNAL_EDITOR); debug_menu->get_popup()->connect("id_pressed", this, "_menu_option"); debug_menu->get_popup()->set_item_disabled(debug_menu->get_popup()->get_item_index(DEBUG_NEXT), true); diff --git a/editor/plugins/script_editor_plugin.h b/editor/plugins/script_editor_plugin.h index e036d1ed9c..3b444c0883 100644 --- a/editor/plugins/script_editor_plugin.h +++ b/editor/plugins/script_editor_plugin.h @@ -141,6 +141,7 @@ class ScriptEditor : public VBoxContainer { DEBUG_CONTINUE, DEBUG_SHOW, DEBUG_SHOW_KEEP_OPEN, + DEBUG_WITH_EXTERNAL_EDITOR, SEARCH_HELP, SEARCH_CLASSES, SEARCH_WEBSITE, diff --git a/editor/plugins/script_text_editor.cpp b/editor/plugins/script_text_editor.cpp index 9f76119374..60fd9d8e30 100644 --- a/editor/plugins/script_text_editor.cpp +++ b/editor/plugins/script_text_editor.cpp @@ -557,6 +557,8 @@ void ScriptEditor::_update_modified_scripts_for_external_editor(Ref<Script> p_fo if (!bool(EditorSettings::get_singleton()->get("text_editor/external/use_external_editor"))) return; + ERR_FAIL_COND(!get_tree()); + Set<Ref<Script> > scripts; Node *base = get_tree()->get_edited_scene_root(); diff --git a/editor/script_editor_debugger.cpp b/editor/script_editor_debugger.cpp index 6d22935dcb..9dce48937c 100644 --- a/editor/script_editor_debugger.cpp +++ b/editor/script_editor_debugger.cpp @@ -1137,8 +1137,9 @@ void ScriptEditorDebugger::_stack_dump_frame_selected() { Dictionary d = ti->get_metadata(0); - Ref<Script> s = ResourceLoader::load(d["file"]); - emit_signal("goto_script_line", s, int(d["line"]) - 1); + stack_script = ResourceLoader::load(d["file"]); + emit_signal("goto_script_line", stack_script, int(d["line"]) - 1); + stack_script.unref(); ERR_FAIL_COND(connection.is_null()); ERR_FAIL_COND(!connection->is_connected_to_host()); @@ -1522,6 +1523,21 @@ void ScriptEditorDebugger::set_hide_on_stop(bool p_hide) { hide_on_stop = p_hide; } +bool ScriptEditorDebugger::get_debug_with_external_editor() const { + + return enable_external_editor; +} + +void ScriptEditorDebugger::set_debug_with_external_editor(bool p_enabled) { + + enable_external_editor = p_enabled; +} + +Ref<Script> ScriptEditorDebugger::get_dump_stack_script() const { + + return stack_script; +} + void ScriptEditorDebugger::_paused() { ERR_FAIL_COND(connection.is_null()); @@ -1871,6 +1887,7 @@ ScriptEditorDebugger::ScriptEditorDebugger(EditorNode *p_editor) { last_path_id = false; error_count = 0; hide_on_stop = true; + enable_external_editor = false; last_error_count = 0; EditorNode::get_singleton()->get_pause_button()->connect("pressed", this, "_paused"); diff --git a/editor/script_editor_debugger.h b/editor/script_editor_debugger.h index 49a4abb6ac..907c267d49 100644 --- a/editor/script_editor_debugger.h +++ b/editor/script_editor_debugger.h @@ -84,6 +84,8 @@ class ScriptEditorDebugger : public Control { int last_error_count; bool hide_on_stop; + bool enable_external_editor; + Ref<Script> stack_script; TabContainer *tabs; @@ -201,6 +203,11 @@ public: void set_hide_on_stop(bool p_hide); + bool get_debug_with_external_editor() const; + void set_debug_with_external_editor(bool p_enabled); + + Ref<Script> get_dump_stack_script() const; + void set_tool_button(Button *p_tb) { debugger_button = p_tb; } void reload_scripts(); diff --git a/modules/gdnative/gdnative.h b/modules/gdnative/gdnative.h index 6716b684a0..650f999192 100644 --- a/modules/gdnative/gdnative.h +++ b/modules/gdnative/gdnative.h @@ -335,7 +335,7 @@ public: virtual bool has_named_classes() const; virtual int find_function(const String &p_function, const String &p_code) const; virtual String make_function(const String &p_class, const String &p_name, const PoolStringArray &p_args) const; - + virtual Error open_in_external_editor(const Ref<Script> &p_script, int p_line, int p_col) { return ERR_UNAVAILABLE; } virtual Error complete_code(const String &p_code, const String &p_base_path, Object *p_owner, List<String> *r_options, String &r_call_hint) { return ERR_UNAVAILABLE; } virtual Error lookup_code(const String &p_code, const String &p_symbol, const String &p_base_path, Object *p_owner, LookupResult &r_result) { return ERR_UNAVAILABLE; } diff --git a/modules/gdscript/gd_script.h b/modules/gdscript/gd_script.h index ebef4fed74..0add348ca9 100644 --- a/modules/gdscript/gd_script.h +++ b/modules/gdscript/gd_script.h @@ -389,6 +389,7 @@ public: virtual bool can_inherit_from_file() { return true; } virtual int find_function(const String &p_function, const String &p_code) const; virtual String make_function(const String &p_class, const String &p_name, const PoolStringArray &p_args) const; + virtual Error open_in_external_editor(const Ref<Script> &p_script, int p_line, int p_col) { return OK; } virtual Error complete_code(const String &p_code, const String &p_base_path, Object *p_owner, List<String> *r_options, String &r_call_hint); #ifdef TOOLS_ENABLED virtual Error lookup_code(const String &p_code, const String &p_symbol, const String &p_base_path, Object *p_owner, LookupResult &r_result); diff --git a/modules/visual_script/visual_script.h b/modules/visual_script/visual_script.h index 1ccc358342..20a1cf49c5 100644 --- a/modules/visual_script/visual_script.h +++ b/modules/visual_script/visual_script.h @@ -571,6 +571,7 @@ public: virtual bool has_named_classes() const; virtual int find_function(const String &p_function, const String &p_code) const; virtual String make_function(const String &p_class, const String &p_name, const PoolStringArray &p_args) const; + virtual Error open_in_external_editor(const Ref<Script> &p_script, int p_line, int p_col) { return ERR_UNAVAILABLE; } virtual void auto_indent_code(String &p_code, int p_from_line, int p_to_line) const; virtual void add_global_constant(const StringName &p_variable, const Variant &p_value); |