From 825a18e980b83ebe62d095c104bfe1a0c479a421 Mon Sep 17 00:00:00 2001 From: kobewi Date: Fri, 29 Sep 2023 19:31:20 +0200 Subject: [PATCH] Don't remove favorite files in EditorFileDialog --- editor/gui/editor_file_dialog.cpp | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/editor/gui/editor_file_dialog.cpp b/editor/gui/editor_file_dialog.cpp index 14d57cbd10c3..22761d37733a 100644 --- a/editor/gui/editor_file_dialog.cpp +++ b/editor/gui/editor_file_dialog.cpp @@ -1393,12 +1393,14 @@ void EditorFileDialog::_update_favorites() { bool fav_changed = false; int current_favorite = -1; for (int i = 0; i < favorited.size(); i++) { - bool cres = favorited[i].begins_with("res://"); - if (cres != res) { + String name = favorited[i]; + + bool cres = name.begins_with("res://"); + if (cres != res || !name.ends_with("/")) { continue; } - if (!dir_access->dir_exists(favorited[i])) { + if (!dir_access->dir_exists(name)) { // Remove invalid directory from the list of Favorited directories. favorited.remove_at(i--); fav_changed = true; @@ -1406,7 +1408,6 @@ void EditorFileDialog::_update_favorites() { } // Compute favorite display text. - String name = favorited[i]; if (res && name == "res://") { if (name == current) { current_favorite = favorited_paths.size(); @@ -1414,7 +1415,7 @@ void EditorFileDialog::_update_favorites() { name = "/"; favorited_paths.append(favorited[i]); favorited_names.append(name); - } else if (name.ends_with("/")) { + } else { if (name == current || name == current + "/") { current_favorite = favorited_paths.size(); } @@ -1422,8 +1423,6 @@ void EditorFileDialog::_update_favorites() { name = name.get_file(); favorited_paths.append(favorited[i]); favorited_names.append(name); - } else { - // Ignore favorited files. } }