diff --git a/editor/filesystem_dock.cpp b/editor/filesystem_dock.cpp index 1cc37457312..19b27698c2e 100644 --- a/editor/filesystem_dock.cpp +++ b/editor/filesystem_dock.cpp @@ -1291,12 +1291,13 @@ void FileSystemDock::_tree_activate_file() { String file_path = selected->get_metadata(0); TreeItem *parent = selected->get_parent(); bool is_favorite = parent != nullptr && parent->get_metadata(0) == "Favorites"; + bool is_folder = file_path.ends_with("/"); - if ((!is_favorite && file_path.ends_with("/")) || file_path == "Favorites") { + if ((!is_favorite && is_folder) || file_path == "Favorites") { bool collapsed = selected->is_collapsed(); selected->set_collapsed(!collapsed); } else { - _select_file(file_path, is_favorite && !file_path.ends_with("/"), false); + _select_file(file_path, is_favorite && !is_folder, is_favorite && is_folder); } } }