Skip to content

Commit f8a2a91

Browse files
committed
Merge pull request #86171 from YuriSizov/editor-what-colors-what-sounds
Fix various issues with the folder color lookup
2 parents c357976 + efa8c46 commit f8a2a91

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

editor/gui/editor_file_dialog.cpp

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -769,19 +769,26 @@ void EditorFileDialog::update_file_name() {
769769

770770
// TODO: Could use a unit test.
771771
Color EditorFileDialog::get_dir_icon_color(const String &p_dir_path) {
772+
if (!FileSystemDock::get_singleton()) { // This dialog can be called from the project manager.
773+
return theme_cache.folder_icon_color;
774+
}
775+
772776
const HashMap<String, Color> &folder_colors = FileSystemDock::get_singleton()->get_folder_colors();
773777
Dictionary assigned_folder_colors = FileSystemDock::get_singleton()->get_assigned_folder_colors();
774778

775779
Color folder_icon_color = theme_cache.folder_icon_color;
776780

777781
// Check for a folder color to inherit (if one is assigned).
778-
String parent_dir = p_dir_path;
779-
while (parent_dir != "res://" && folder_icon_color == theme_cache.folder_icon_color) {
782+
String parent_dir = ProjectSettings::get_singleton()->localize_path(p_dir_path);
783+
while (!parent_dir.is_empty() && parent_dir != "res://") {
780784
if (!parent_dir.ends_with("/")) {
781785
parent_dir += "/";
782786
}
783787
if (assigned_folder_colors.has(parent_dir)) {
784788
folder_icon_color = folder_colors[assigned_folder_colors[parent_dir]];
789+
if (folder_icon_color != theme_cache.folder_icon_color) {
790+
break;
791+
}
785792
}
786793
parent_dir = parent_dir.trim_suffix("/").get_base_dir();
787794
}

0 commit comments

Comments
 (0)