### Godot version

3.5.1mono

### System information

windows10

### Issue description

Error message
 scene/main/node.cpp:1362 - Index p_index = 0 is out of bounds (data.children.size() = 0).
 scene/main/node.cpp:397 - Parameter "p_child" is null.
 scene/gui/tab_container.cpp:593 - Index p_current = 0 is out of bounds (get_tab_count() = 0).
See "Steps to reproduce for details"

### Steps to reproduce

Set an external text editor
Create a script
Drop the script to the built-in text editor like this image:
![image](https://user-images.githubusercontent.com/119792950/209504041-039f2620-5e42-4c0f-8c41-cd24486fb3d2.png)
And got error message:
 scene/main/node.cpp:1362 - Index p_index = 0 is out of bounds (data.children.size() = 0).
 scene/main/node.cpp:397 - Parameter "p_child" is null.
 scene/gui/tab_container.cpp:593 - Index p_current = 0 is out of bounds (get_tab_count() = 0).

### Minimal reproduction project

An empty project
EditorNode::get_singleton()->show_warning(TTR("Can't obtain the script for running."));
					break;
				}
				if (!scr->is_tool()) {
					EditorNode::get_singleton()->show_warning(TTR("Script is not in tool mode, will not be able to run."));
					return;
				}
				current->apply_code();
				Error err = scr->reload(false); 
				if (err != OK) {
					EditorNode::get_singleton()->show_warning(TTR("Script failed reloading, check console for errors."));
					return;
				}
				if (!ClassDB::is_parent_class(scr->get_instance_base_type(), "EditorScript")) {
					EditorNode::get_singleton()->show_warning(TTR("To run this script, it must inherit EditorScript and be set to tool mode."));
					return;
				}
				Ref<EditorScript> es = memnew(EditorScript);
				es->set_script(scr);
				es->set_editor(EditorNode::get_singleton());
				es->_run();
			} break;
			case FILE_CLOSE: {
				if (current->is_unsaved()) {
					_ask_close_current_unsaved_tab(current);
				} else {
					_close_current_tab(false);
				}
			} break;
			case FILE_COPY_PATH: {