diff options
author | geequlim <geequlim@gmail.com> | 2017-06-25 17:20:01 +0800 |
---|---|---|
committer | geequlim <geequlim@gmail.com> | 2017-06-27 12:55:16 +0800 |
commit | 6687484958412ff0f3bd6d97cbc1fcebc7ae64d2 (patch) | |
tree | fdeae7b3668b0ff1d7c84f38741a9762d224f260 /editor/plugins | |
parent | 87fd71244be7b185f0525c6b33850f7075b1425a (diff) |
Better user expirence with external text editors.
Implements open_in_external_editor for subclasses of ScriptLanguage.
Add option 'Debug with external editor' to debug menu to control the behavoir of script opened by editor.
Diffstat (limited to 'editor/plugins')
-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 |
3 files changed, 20 insertions, 7 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(); |