### 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
autosave_timer = memnew(Timer);
	autosave_timer->set_one_shot(false);
	autosave_timer->connect(SceneStringNames::get_singleton()->tree_entered, callable_mp(this, &ScriptEditor::_update_autosave_timer));
	autosave_timer->connect("timeout", callable_mp(this, &ScriptEditor::_autosave_scripts));
	add_child(autosave_timer);
	grab_focus_block = false;
	help_search_dialog = memnew(EditorHelpSearch);
	add_child(help_search_dialog);
	help_search_dialog->connect("go_to_help", callable_mp(this, &ScriptEditor::_help_class_goto));
	find_in_files_dialog = memnew(FindInFilesDialog);
	find_in_files_dialog->connect(FindInFilesDialog::SIGNAL_FIND_REQUESTED, callable_mp(this, &ScriptEditor::_start_find_in_files).bind(false));
	find_in_files_dialog->connect(FindInFilesDialog::SIGNAL_REPLACE_REQUESTED, callable_mp(this, &ScriptEditor::_start_find_in_files).bind(true));
	add_child(find_in_files_dialog);
	find_in_files = memnew(FindInFilesPanel);
	find_in_files_button = EditorNode::get_singleton()->add_bottom_panel_item(TTR("Search Results"), find_in_files);
	find_in_files->set_custom_minimum_size(Size2(0, 200) * EDSCALE);
	find_in_files->connect(FindInFilesPanel::SIGNAL_RESULT_SELECTED, callable_mp(this, &ScriptEditor::_on_find_in_files_result_selected));
	find_in_files->connect(FindInFilesPanel::SIGNAL_FILES_MODIFIED, callable_mp(this, &ScriptEditor::_on_find_in_files_modified_files));
	find_in_files->hide();
	find_in_files_button->hide();
	history_pos = -1;
	edit_pass = 0;
	trim_trailing_whitespace_on_save = EDITOR_GET("text_editor/behavior/files/trim_trailing_whitespace_on_save");
	convert_indent_on_save = EDITOR_GET("text_editor/behavior/files/convert_indent_on_save");
	use_space_indentation = EDITOR_GET("text_editor/behavior/indent/type");
	ScriptServer::edit_request_func = _open_script_request;
	add_theme_style_override("panel", EditorNode::get_singleton()->get_gui_base()->get_theme_stylebox(SNAME("ScriptEditorPanel"), SNAME("EditorStyles")));
	tab_container->add_theme_style_override("panel", EditorNode::get_singleton()->get_gui_base()->get_theme_stylebox(SNAME("ScriptEditor"), SNAME("EditorStyles")));
}
ScriptEditor::~ScriptEditor() {