Merge pull request #90280 from TheSofox/duplicated-folder-reference-fix

Fix duplicated folder reference in Godot Editor after changing filename case
This commit is contained in:
Rémi Verschelde 2024-04-06 13:06:57 +02:00
commit 66dbe3591b
No known key found for this signature in database
GPG key ID: C3336907360768E1

View file

@ -1367,6 +1367,10 @@ bool EditorFileSystem::_find_file(const String &p_file, EditorFileSystemDirector
String f = ProjectSettings::get_singleton()->localize_path(p_file);
// Note: Only checks if base directory is case sensitive.
Ref<DirAccess> dir = DirAccess::create(DirAccess::ACCESS_FILESYSTEM);
bool fs_case_sensitive = dir->is_case_sensitive("res://");
if (!f.begins_with("res://")) {
return false;
}
@ -1390,9 +1394,16 @@ bool EditorFileSystem::_find_file(const String &p_file, EditorFileSystemDirector
int idx = -1;
for (int j = 0; j < fs->get_subdir_count(); j++) {
if (fs->get_subdir(j)->get_name() == path[i]) {
idx = j;
break;
if (fs_case_sensitive) {
if (fs->get_subdir(j)->get_name() == path[i]) {
idx = j;
break;
}
} else {
if (fs->get_subdir(j)->get_name().to_lower() == path[i].to_lower()) {
idx = j;
break;
}
}
}