### 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
void _tree_gui_input(Ref<InputEvent> p_event);
	void _update_file_list(bool p_keep_selection);
	void _toggle_file_display();
	void _set_file_display(bool p_active);
	void _fs_changed();
	void _select_file(const String &p_path, bool p_select_in_favorites = false);
	void _tree_activate_file();
	void _file_list_activate_file(int p_idx);
	void _file_multi_selected(int p_index, bool p_selected);
	void _tree_multi_selected(Object *p_item, int p_column, bool p_selected);
	bool _get_imported_files(const String &p_path, String &r_extension, Vector<String> &r_files) const;
	void _update_import_dock();
	void _get_all_items_in_dir(EditorFileSystemDirectory *p_efsd, Vector<String> &r_files, Vector<String> &r_folders) const;
	void _find_remaps(EditorFileSystemDirectory *p_efsd, const HashMap<String, String> &r_renames, Vector<String> &r_to_remaps) const;
	void _try_move_item(const FileOrFolder &p_item, const String &p_new_path, HashMap<String, String> &p_file_renames, HashMap<String, String> &p_folder_renames);
	void _try_duplicate_item(const FileOrFolder &p_item, const String &p_new_path) const;
	void _update_dependencies_after_move(const HashMap<String, String> &p_renames) const;
	void _update_resource_paths_after_move(const HashMap<String, String> &p_renames) const;
	void _save_scenes_after_move(const HashMap<String, String> &p_renames) const;
	void _update_favorites_list_after_move(const HashMap<String, String> &p_files_renames, const HashMap<String, String> &p_folders_renames) const;
	void _update_project_settings_after_move(const HashMap<String, String> &p_renames) const;
	String _get_unique_name(const FileOrFolder &p_entry, const String &p_at_path);
	void _resource_removed(const Ref<Resource> &p_resource);
	void _file_removed(String p_file);
	void _folder_removed(String p_folder);
	void _resource_created();
	void _make_scene_confirm();
	void _rename_operation_confirm();
	void _duplicate_operation_confirm();
	void _overwrite_dialog_action(bool p_overwrite);