### 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
file_menu->get_popup()->add_separator();
	file_menu->get_popup()->add_shortcut(ED_SHORTCUT("script_editor/run_file", TTR("Run"), KeyModifierMask::CMD_OR_CTRL | KeyModifierMask::SHIFT | Key::X), FILE_RUN);
	file_menu->get_popup()->add_separator();
	file_menu->get_popup()->add_shortcut(ED_SHORTCUT("script_editor/toggle_scripts_panel", TTR("Toggle Scripts Panel"), KeyModifierMask::CMD_OR_CTRL | Key::BACKSLASH), TOGGLE_SCRIPTS_PANEL);
	file_menu->get_popup()->connect("id_pressed", callable_mp(this, &ScriptEditor::_menu_option));
	file_menu->get_popup()->connect("about_to_popup", callable_mp(this, &ScriptEditor::_prepare_file_menu));
	script_search_menu = memnew(MenuButton);
	script_search_menu->set_text(TTR("Search"));
	script_search_menu->set_switch_on_hover(true);
	script_search_menu->set_shortcut_context(this);
	script_search_menu->get_popup()->connect("id_pressed", callable_mp(this, &ScriptEditor::_menu_option));
	menu_hb->add_child(script_search_menu);
	MenuButton *debug_menu_btn = memnew(MenuButton);
	menu_hb->add_child(debug_menu_btn);
	debug_menu_btn->hide(); 
	EditorDebuggerNode *debugger = EditorDebuggerNode::get_singleton();
	debugger->set_script_debug_button(debug_menu_btn);
	debugger->connect("goto_script_line", callable_mp(this, &ScriptEditor::_goto_script_line));
	debugger->connect("set_execution", callable_mp(this, &ScriptEditor::_set_execution));
	debugger->connect("clear_execution", callable_mp(this, &ScriptEditor::_clear_execution));
	debugger->connect("breaked", callable_mp(this, &ScriptEditor::_breaked));
	debugger->get_default_debugger()->connect("set_breakpoint", callable_mp(this, &ScriptEditor::_set_breakpoint));
	debugger->get_default_debugger()->connect("clear_breakpoints", callable_mp(this, &ScriptEditor::_clear_breakpoints));
	menu_hb->add_spacer();
	script_icon = memnew(TextureRect);
	menu_hb->add_child(script_icon);
	script_name_label = memnew(Label);
	menu_hb->add_child(script_name_label);
	script_icon->hide();
	script_name_label->hide();