### 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
FileOrFolder(const String &p_path, bool p_is_file) :
				path(p_path),
				is_file(p_is_file) {}
	};
	FileOrFolder to_rename;
	FileOrFolder to_duplicate;
	Vector<FileOrFolder> to_move;
	String to_move_path;
	bool to_move_or_copy = false;
	Vector<String> history;
	int history_pos;
	int history_max_size;
	String current_path;
	bool initialized = false;
	bool updating_tree = false;
	int tree_update_id;
	FileSystemTree *tree = nullptr;
	FileSystemList *files = nullptr;
	bool import_dock_needs_update = false;
	bool holding_branch = false;
	Vector<TreeItem *> tree_items_selected_on_drag_begin;
	PackedInt32Array list_items_selected_on_drag_begin;
	LocalVector<Ref<EditorResourceTooltipPlugin>> tooltip_plugins;
	void _tree_mouse_exited();
	void _reselect_items_selected_on_drag_begin(bool reset = false);
	Ref<Texture2D> _get_tree_item_icon(bool p_is_valid, String p_file_type);
	bool _create_tree(TreeItem *p_parent, EditorFileSystemDirectory *p_dir, Vector<String> &uncollapsed_paths, bool p_select_in_favorites, bool p_unfold_path = false);
	void _update_tree(const Vector<String> &p_uncollapsed_paths = Vector<String>(), bool p_uncollapse_root = false, bool p_select_in_favorites = false, bool p_unfold_path = false);
	void _navigate_to_path(const String &p_path, bool p_select_in_favorites = false);
	void _file_list_gui_input(Ref<InputEvent> p_event);