### 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
return NaturalNoCaseComparator()(name, fi.name);
		}
	};
	struct FileInfoTypeComparator;
	struct FileInfoModifiedTimeComparator;
	void _sort_file_info_list(List<FileSystemDock::FileInfo> &r_file_list);
	void _search(EditorFileSystemDirectory *p_path, List<FileInfo> *matches, int p_max_items);
	void _set_current_path_line_edit_text(const String &p_path);
	Variant get_drag_data_fw(const Point2 &p_point, Control *p_from);
	bool can_drop_data_fw(const Point2 &p_point, const Variant &p_data, Control *p_from) const;
	void drop_data_fw(const Point2 &p_point, const Variant &p_data, Control *p_from);
	void _get_drag_target_folder(String &target, bool &target_favorites, const Point2 &p_point, Control *p_from) const;
	void _preview_invalidated(const String &p_path);
	void _file_list_thumbnail_done(const String &p_path, const Ref<Texture2D> &p_preview, const Ref<Texture2D> &p_small_preview, const Variant &p_udata);
	void _tree_thumbnail_done(const String &p_path, const Ref<Texture2D> &p_preview, const Ref<Texture2D> &p_small_preview, const Variant &p_udata);
	void _update_display_mode(bool p_force = false);
	Vector<String> _tree_get_selected(bool remove_self_inclusion = true) const;
	bool _is_file_type_disabled_by_feature_profile(const StringName &p_class);
	void _feature_profile_changed();
	static Vector<String> _remove_self_included_paths(Vector<String> selected_strings);
private:
	static FileSystemDock *singleton;
public:
	static FileSystemDock *get_singleton() { return singleton; }