diff options
-rw-r--r-- | core/script_language.h | 1 | ||||
-rw-r--r-- | editor/editor_node.cpp | 13 | ||||
-rw-r--r-- | editor/plugins/script_editor_plugin.cpp | 8 | ||||
-rw-r--r-- | modules/gdscript/gd_script.h | 1 | ||||
-rw-r--r-- | modules/visual_script/visual_script.h | 1 |
5 files changed, 20 insertions, 4 deletions
diff --git a/core/script_language.h b/core/script_language.h index 342d8c8072..2261737f9a 100644 --- a/core/script_language.h +++ b/core/script_language.h @@ -206,6 +206,7 @@ public: virtual int find_function(const String &p_function, const String &p_code) const = 0; virtual String make_function(const String &p_class, const String &p_name, const PoolStringArray &p_args) const = 0; virtual Error open_in_external_editor(const Ref<Script> &p_script, int p_line, int p_col) { return ERR_UNAVAILABLE; } + virtual bool overrides_external_editor() { return false; } virtual Error complete_code(const String &p_code, const String &p_base_path, Object *p_owner, List<String> *r_options, bool &r_force, String &r_call_hint) { return ERR_UNAVAILABLE; } diff --git a/editor/editor_node.cpp b/editor/editor_node.cpp index 6b5db7572a..d4e0aacb0f 100644 --- a/editor/editor_node.cpp +++ b/editor/editor_node.cpp @@ -1368,6 +1368,16 @@ void EditorNode::_set_editing_top_editors(Object *p_current_object) { editor_plugins_over->edit(p_current_object); } +static bool overrides_external_editor(Object *p_object) { + + Script *script = Object::cast_to<Script>(p_object); + + if (!script) + return false; + + return script->get_language()->overrides_external_editor(); +} + void EditorNode::_edit_current() { uint32_t current = editor_history.get_current(); @@ -1434,7 +1444,7 @@ void EditorNode::_edit_current() { if (main_plugin) { // special case if use of external editor is true - if (main_plugin->get_name() == "Script" && bool(EditorSettings::get_singleton()->get("text_editor/external/use_external_editor"))) { + if (main_plugin->get_name() == "Script" && (bool(EditorSettings::get_singleton()->get("text_editor/external/use_external_editor")) || overrides_external_editor(current_obj))) { main_plugin->edit(current_obj); } @@ -1442,6 +1452,7 @@ void EditorNode::_edit_current() { // update screen main_plugin if (!changing_scene) { + if (editor_plugin_screen) editor_plugin_screen->make_visible(false); editor_plugin_screen = main_plugin; diff --git a/editor/plugins/script_editor_plugin.cpp b/editor/plugins/script_editor_plugin.cpp index a529f152dc..3033df7630 100644 --- a/editor/plugins/script_editor_plugin.cpp +++ b/editor/plugins/script_editor_plugin.cpp @@ -1539,8 +1539,14 @@ 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"); + if (p_script->get_language()->overrides_external_editor()) { + Error err = p_script->get_language()->open_in_external_editor(p_script, p_line >= 0 ? p_line : 0, p_col); + if (err != OK) + ERR_PRINT("Couldn't open script in the overridden external text editor"); + return false; + } + 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"))) { diff --git a/modules/gdscript/gd_script.h b/modules/gdscript/gd_script.h index 6f05a4770b..5e1a8b19ac 100644 --- a/modules/gdscript/gd_script.h +++ b/modules/gdscript/gd_script.h @@ -389,7 +389,6 @@ 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, bool &r_forced, 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 b2e7a6aa27..297e9e510f 100644 --- a/modules/visual_script/visual_script.h +++ b/modules/visual_script/visual_script.h @@ -571,7 +571,6 @@ 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); |