### Godot version

v4.1.dev3.official [a67d37f7c]

### System information

Windows 10 64-bit

### Issue description

When trying to rename anything (a scene, script, folder, etc) instead of selecting the item itself, it highlights the current folder in the FileSystem tab instead.

Upon pressing enter or confirm the name change a Warning dialogue appears with the following text:

> This file extension is not recognized by the editor.
If you want to rename it anyway, use your operating system's file manager.
After renaming to an unknown extension, the file won't be shown in the editor anymore.

If no new text is entered, the warning box instead states

> Name contains invalid characters.

Upon pressing Ok, the folder name in the FileSystem tab is visually changed to match the name of the item you attempted to rename (regardless of the entered text) including the extension if any. The folder name remains the same in the file system, but visually in the editor it is the name of the item.
In the output log, there is a message
> scene/main/viewport.cpp:3005 - Condition "!is_inside_tree()" is true.

![sample](https://github.com/godotengine/godot/assets/9257713/35ee2446-507b-4cfb-a9ab-6d46ae484feb)

### Steps to reproduce

1. Create or open a project
2. Rename any item (scene, script, folder, etc) by right clicking or pressing F2 (or corresponding shortcut for rename)

### Minimal reproduction project

N/A
Vector<String> _check_existing();
	void _move_dialog_confirm(const String &p_path);
	void _move_operation_confirm(const String &p_to_path, bool p_copy = false, Overwrite p_overwrite = OVERWRITE_UNDECIDED);
	void _tree_rmb_option(int p_option);
	void _file_list_rmb_option(int p_option);
	void _file_option(int p_option, const Vector<String> &p_selected);
	void _fw_history();
	void _bw_history();
	void _update_history();
	void _push_to_history();
	void _set_scanning_mode();
	void _rescan();
	void _toggle_split_mode(bool p_active);
	void _search_changed(const String &p_text, const Control *p_from);
	MenuButton *_create_file_menu_button();
	void _file_sort_popup(int p_id);
	void _file_and_folders_fill_popup(PopupMenu *p_popup, Vector<String> p_paths, bool p_display_path_dependent_options = true);
	void _tree_rmb_select(const Vector2 &p_pos, MouseButton p_button);
	void _file_list_item_clicked(int p_item, const Vector2 &p_pos, MouseButton p_mouse_button_index);
	void _file_list_empty_clicked(const Vector2 &p_pos, MouseButton p_mouse_button_index);
	void _tree_empty_click(const Vector2 &p_pos, MouseButton p_button);
	void _tree_empty_selected();
	struct FileInfo {
		String name;
		String path;
		StringName type;
		Vector<String> sources;
		bool import_broken = false;
		uint64_t modified_time = 0;
		bool operator<(const FileInfo &fi) const {