| 772 | } |
| 773 | |
| 774 | void Content_SearchFilesAsync(String path, std::vector<std::string>&& exts, Dictionary* extensionLevels, std::vector<std::string>&& excludes, String pattern, bool useRegex, bool caseSensitive, bool includeContent, int contentWindow, std::function<bool(Dictionary* result)> callback) { |
| 775 | std::unordered_map<std::string, int> extLevels; |
| 776 | auto keys = extensionLevels->getKeys(); |
| 777 | extLevels.reserve(keys.size()); |
| 778 | for (const auto& key : keys) { |
| 779 | const auto& value = extensionLevels->get(key); |
| 780 | if (!value) continue; |
| 781 | if (auto intVal = value->asVal<int64_t>()) { |
| 782 | extLevels[key.toString()] = s_cast<int>(*intVal); |
| 783 | } else if (auto floatVal = value->asVal<double>()) { |
| 784 | extLevels[key.toString()] = s_cast<int>(*floatVal); |
| 785 | } |
| 786 | } |
| 787 | SharedContent.searchFilesAsync( |
| 788 | path, |
| 789 | std::move(exts), |
| 790 | std::move(extLevels), |
| 791 | std::move(excludes), |
| 792 | pattern, |
| 793 | useRegex, |
| 794 | caseSensitive, |
| 795 | includeContent, |
| 796 | contentWindow, |
| 797 | [callback](Content::SearchResult&& res) { |
| 798 | if (res.file.empty()) { |
| 799 | return callback(Dictionary::create()); |
| 800 | } |
| 801 | auto result = Dictionary::create(); |
| 802 | result->set("file"sv, Value::alloc(res.file)); |
| 803 | result->set("pos"sv, Value::alloc(s_cast<int64_t>(res.pos))); |
| 804 | result->set("line"sv, Value::alloc(res.line)); |
| 805 | result->set("column"sv, Value::alloc(res.column)); |
| 806 | result->set("content"sv, Value::alloc(res.content)); |
| 807 | return callback(result); |
| 808 | }); |
| 809 | } |
| 810 | |
| 811 | /* Rect */ |
| 812 |
no test coverage detected