|
@@ -2890,12 +2890,19 @@ void FileSystemDock::_file_list_gui_input(Ref<InputEvent> p_event) {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-void FileSystemDock::_get_imported_files(const String &p_path, Vector<String> &r_files) const {
|
|
|
+bool FileSystemDock::_get_imported_files(const String &p_path, String &r_extension, Vector<String> &r_files) const {
|
|
|
if (!p_path.ends_with("/")) {
|
|
|
if (FileAccess::exists(p_path + ".import")) {
|
|
|
+ if (r_extension.is_empty()) {
|
|
|
+ r_extension = p_path.get_extension();
|
|
|
+ } else if (r_extension != p_path.get_extension()) {
|
|
|
+ r_files.clear();
|
|
|
+ return false; // File type mismatch, stop search.
|
|
|
+ }
|
|
|
+
|
|
|
r_files.push_back(p_path);
|
|
|
}
|
|
|
- return;
|
|
|
+ return true;
|
|
|
}
|
|
|
|
|
|
Ref<DirAccess> da = DirAccess::open(p_path);
|
|
@@ -2904,11 +2911,14 @@ void FileSystemDock::_get_imported_files(const String &p_path, Vector<String> &r
|
|
|
while (!n.is_empty()) {
|
|
|
if (n != "." && n != ".." && !n.ends_with(".import")) {
|
|
|
String npath = p_path + n + (da->current_is_dir() ? "/" : "");
|
|
|
- _get_imported_files(npath, r_files);
|
|
|
+ if (!_get_imported_files(npath, r_extension, r_files)) {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
}
|
|
|
n = da->get_next();
|
|
|
}
|
|
|
da->list_dir_end();
|
|
|
+ return true;
|
|
|
}
|
|
|
|
|
|
void FileSystemDock::_update_import_dock() {
|
|
@@ -2933,10 +2943,16 @@ void FileSystemDock::_update_import_dock() {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- // Expand directory selection
|
|
|
+ if (!selected.is_empty() && selected[0] == "res://") {
|
|
|
+ // Scanning res:// is costly and unlikely to yield any useful results.
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ // Expand directory selection.
|
|
|
Vector<String> efiles;
|
|
|
- for (int i = 0; i < selected.size(); i++) {
|
|
|
- _get_imported_files(selected[i], efiles);
|
|
|
+ String extension;
|
|
|
+ for (const String &fpath : selected) {
|
|
|
+ _get_imported_files(fpath, extension, efiles);
|
|
|
}
|
|
|
|
|
|
// Check import.
|