Skip to content

Commit

Permalink
Merge pull request #10939 from neikeq/fix-overridden-external-editors
Browse files Browse the repository at this point in the history
Fixes language overridden external editors
  • Loading branch information
akien-mga authored Sep 4, 2017
2 parents 0f5e575 + 52a7be4 commit b5d2d0a
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 4 deletions.
1 change: 1 addition & 0 deletions core/script_language.h
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,7 @@ class ScriptLanguage {
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; }

Expand Down
13 changes: 12 additions & 1 deletion editor/editor_node.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -1434,14 +1444,15 @@ 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);
}

else if (main_plugin != editor_plugin_screen && (!ScriptEditor::get_singleton() || !ScriptEditor::get_singleton()->is_visible_in_tree() || ScriptEditor::get_singleton()->can_take_away_focus())) {
// update screen main_plugin

if (!changing_scene) {

if (editor_plugin_screen)
editor_plugin_screen->make_visible(false);
editor_plugin_screen = main_plugin;
Expand Down
8 changes: 7 additions & 1 deletion editor/plugins/script_editor_plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1545,8 +1545,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"))) {

Expand Down
1 change: 0 additions & 1 deletion modules/gdscript/gd_script.h
Original file line number Diff line number Diff line change
Expand Up @@ -389,7 +389,6 @@ class GDScriptLanguage : public ScriptLanguage {
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);
Expand Down
1 change: 0 additions & 1 deletion modules/visual_script/visual_script.h
Original file line number Diff line number Diff line change
Expand Up @@ -571,7 +571,6 @@ class VisualScriptLanguage : public ScriptLanguage {
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);

Expand Down

0 comments on commit b5d2d0a

Please sign in to comment.