Skip to content

Commit f38b707

Browse files
committed
Refactor _edit_current script check
Restore changing_scene check and bool()
1 parent 2d86b69 commit f38b707

File tree

1 file changed

+9
-17
lines changed

1 file changed

+9
-17
lines changed

editor/editor_node.cpp

Lines changed: 9 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2918,16 +2918,6 @@ void EditorNode::hide_unused_editors(const Object *p_editing_owner) {
29182918
}
29192919
}
29202920

2921-
static bool overrides_external_editor(Object *p_object) {
2922-
Script *script = Object::cast_to<Script>(p_object);
2923-
2924-
if (!script) {
2925-
return false;
2926-
}
2927-
2928-
return script->get_language()->overrides_external_editor();
2929-
}
2930-
29312921
void EditorNode::_add_to_history(const Object *p_object, const String &p_property, bool p_inspector_only) {
29322922
ObjectID id = p_object->get_instance_id();
29332923
ObjectID history_id = editor_history.get_current();
@@ -3116,15 +3106,17 @@ void EditorNode::_edit_current(bool p_skip_foreign, bool p_skip_inspector_update
31163106

31173107
ObjectID editor_owner_id = editor_owner->get_instance_id();
31183108
if (main_plugin && !skip_main_plugin) {
3119-
// Special case if use of external editor is true.
3120-
Resource *current_res = Object::cast_to<Resource>(current_obj);
3121-
if (main_plugin->get_plugin_name() == "Script" && current_res && !current_res->is_built_in() && (bool(EDITOR_GET("text_editor/external/use_external_editor")) || overrides_external_editor(current_obj))) {
3109+
// Special case if current_obj is a script.
3110+
Script *current_script = Object::cast_to<Script>(current_obj);
3111+
if (current_script) {
31223112
if (!changing_scene) {
3123-
main_plugin->edit(current_obj);
3113+
// Only update main editor screen if using in-engine editor.
3114+
if (current_script->is_built_in() || (!bool(EDITOR_GET("text_editor/external/use_external_editor")) && !current_script->get_language()->overrides_external_editor())) {
3115+
editor_main_screen->select(plugin_index);
3116+
}
3117+
3118+
main_plugin->edit(current_script);
31243119
}
3125-
} else if (Object::cast_to<Script>(current_obj)) {
3126-
editor_main_screen->select(plugin_index);
3127-
main_plugin->edit(current_obj);
31283120
} else if (main_plugin != editor_plugin_screen) {
31293121
// Unedit previous plugin.
31303122
editor_plugin_screen->edit(nullptr);

0 commit comments

Comments
 (0)