Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Stop the searching of find in files in folders that have .gdignore #85943

Merged
merged 1 commit into from
Jan 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 9 additions & 4 deletions editor/find_in_files.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -172,9 +172,11 @@ void FindInFiles::_iterate() {
_current_dir = _current_dir.path_join(folder_name);

PackedStringArray sub_dirs;
_scan_dir("res://" + _current_dir, sub_dirs);
PackedStringArray files_to_scan;
_scan_dir("res://" + _current_dir, sub_dirs, files_to_scan);

_folders_stack.push_back(sub_dirs);
_files_to_scan.append_array(files_to_scan);

} else {
// Go back one level.
Expand Down Expand Up @@ -211,7 +213,7 @@ float FindInFiles::get_progress() const {
return 0;
}

void FindInFiles::_scan_dir(String path, PackedStringArray &out_folders) {
void FindInFiles::_scan_dir(String path, PackedStringArray &out_folders, PackedStringArray &out_files_to_scan) {
Ref<DirAccess> dir = DirAccess::open(path);
if (dir.is_null()) {
print_verbose("Cannot open directory! " + path);
Expand All @@ -227,8 +229,11 @@ void FindInFiles::_scan_dir(String path, PackedStringArray &out_folders) {
break;
}

// If there is a .gdignore file in the directory, skip searching the directory.
// If there is a .gdignore file in the directory, clear all the files/folders
// to be searched on this path and skip searching the directory.
if (file == ".gdignore") {
out_folders.clear();
out_files_to_scan.clear();
break;
}

Expand All @@ -247,7 +252,7 @@ void FindInFiles::_scan_dir(String path, PackedStringArray &out_folders) {
} else {
String file_ext = file.get_extension();
if (_extension_filter.has(file_ext)) {
_files_to_scan.push_back(path.path_join(file));
out_files_to_scan.push_back(path.path_join(file));
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion editor/find_in_files.h
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ class FindInFiles : public Node {
private:
void _process();
void _iterate();
void _scan_dir(String path, PackedStringArray &out_folders);
void _scan_dir(String path, PackedStringArray &out_folders, PackedStringArray &out_files_to_scan);
void _scan_file(String fpath);

// Config
Expand Down
Loading