1
0
mirror of https://github.com/godotengine/godot.git synced 2025-12-02 16:48:55 +00:00

Refactor _edit_current script check

Restore changing_scene check and bool()
This commit is contained in:
SchultzenDK
2025-08-15 21:49:36 +02:00
parent 2d86b69bf1
commit f38b7071ce

View File

@@ -2918,16 +2918,6 @@ void EditorNode::hide_unused_editors(const Object *p_editing_owner) {
} }
} }
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::_add_to_history(const Object *p_object, const String &p_property, bool p_inspector_only) { void EditorNode::_add_to_history(const Object *p_object, const String &p_property, bool p_inspector_only) {
ObjectID id = p_object->get_instance_id(); ObjectID id = p_object->get_instance_id();
ObjectID history_id = editor_history.get_current(); ObjectID history_id = editor_history.get_current();
@@ -3116,15 +3106,17 @@ void EditorNode::_edit_current(bool p_skip_foreign, bool p_skip_inspector_update
ObjectID editor_owner_id = editor_owner->get_instance_id(); ObjectID editor_owner_id = editor_owner->get_instance_id();
if (main_plugin && !skip_main_plugin) { if (main_plugin && !skip_main_plugin) {
// Special case if use of external editor is true. // Special case if current_obj is a script.
Resource *current_res = Object::cast_to<Resource>(current_obj); Script *current_script = Object::cast_to<Script>(current_obj);
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))) { if (current_script) {
if (!changing_scene) { if (!changing_scene) {
main_plugin->edit(current_obj); // Only update main editor screen if using in-engine editor.
if (current_script->is_built_in() || (!bool(EDITOR_GET("text_editor/external/use_external_editor")) && !current_script->get_language()->overrides_external_editor())) {
editor_main_screen->select(plugin_index);
}
main_plugin->edit(current_script);
} }
} else if (Object::cast_to<Script>(current_obj)) {
editor_main_screen->select(plugin_index);
main_plugin->edit(current_obj);
} else if (main_plugin != editor_plugin_screen) { } else if (main_plugin != editor_plugin_screen) {
// Unedit previous plugin. // Unedit previous plugin.
editor_plugin_screen->edit(nullptr); editor_plugin_screen->edit(nullptr);