diff options
Diffstat (limited to 'editor/find_in_files.cpp')
-rw-r--r-- | editor/find_in_files.cpp | 22 |
1 files changed, 10 insertions, 12 deletions
diff --git a/editor/find_in_files.cpp b/editor/find_in_files.cpp index 9442bbc0e8..004a49e2b4 100644 --- a/editor/find_in_files.cpp +++ b/editor/find_in_files.cpp @@ -109,6 +109,7 @@ void FindInFiles::start() { _current_dir = ""; PoolStringArray init_folder; init_folder.append(_root_dir); + _folders_stack.clear(); _folders_stack.push_back(init_folder); _initial_files_count = 0; @@ -127,11 +128,12 @@ void FindInFiles::_process() { // This part can be moved to a thread if needed OS &os = *OS::get_singleton(); - float duration = 0.0; - while (duration < 1.0 / 120.0) { - float time_before = os.get_ticks_msec(); + float time_before = os.get_ticks_msec(); + while (is_processing()) { _iterate(); - duration += (os.get_ticks_msec() - time_before); + float elapsed = (os.get_ticks_msec() - time_before); + if (elapsed > 1000.0 / 120.0) + break; } } @@ -154,9 +156,7 @@ void FindInFiles::_iterate() { PoolStringArray sub_dirs; _scan_dir(_root_prefix + _current_dir, sub_dirs); - if (sub_dirs.size() != 0) { - _folders_stack.push_back(sub_dirs); - } + _folders_stack.push_back(sub_dirs); } else { // Go back one level @@ -176,7 +176,7 @@ void FindInFiles::_iterate() { String fpath = _files_to_scan[_files_to_scan.size() - 1]; pop_back(_files_to_scan); - _scan_file(_root_prefix + fpath); + _scan_file(fpath); } else { print_line("Search complete"); @@ -202,8 +202,6 @@ void FindInFiles::_scan_dir(String path, PoolStringArray &out_folders) { return; } - //print_line(String("Scanning ") + path); - dir->list_dir_begin(); for (int i = 0; i < 1000; ++i) { @@ -222,7 +220,7 @@ void FindInFiles::_scan_dir(String path, PoolStringArray &out_folders) { else { String file_ext = file.get_extension(); if (_extension_filter.has(file_ext)) { - _files_to_scan.push_back(file); + _files_to_scan.push_back(path.plus_file(file)); } } } @@ -232,7 +230,6 @@ void FindInFiles::_scan_file(String fpath) { FileAccess *f = FileAccess::open(fpath, FileAccess::READ); if (f == NULL) { - f->close(); print_line(String("Cannot open file ") + fpath); return; } @@ -433,6 +430,7 @@ FindInFilesDialog::FindInFilesDialog() { void FindInFilesDialog::set_search_text(String text) { _search_text_line_edit->set_text(text); + _on_search_text_modified(text); } String FindInFilesDialog::get_search_text() const { |