()
| 161 | // The "Worker" that performs async operations based on status. |
| 162 | useEffect(() => { |
| 163 | const initialize = async () => { |
| 164 | try { |
| 165 | const searcher = FileSearchFactory.create({ |
| 166 | projectRoot: cwd, |
| 167 | ignoreDirs: [], |
| 168 | useGitignore: |
| 169 | config?.getFileFilteringOptions()?.respectGitIgnore ?? true, |
| 170 | useAnusignore: |
| 171 | config?.getFileFilteringOptions()?.respectAnusIgnore ?? true, |
| 172 | cache: true, |
| 173 | cacheTtl: 30, // 30 seconds |
| 174 | enableRecursiveFileSearch: |
| 175 | config?.getEnableRecursiveFileSearch() ?? true, |
| 176 | }); |
| 177 | await searcher.initialize(); |
| 178 | fileSearch.current = searcher; |
| 179 | dispatch({ type: 'INITIALIZE_SUCCESS' }); |
| 180 | if (state.pattern !== null) { |
| 181 | dispatch({ type: 'SEARCH', payload: state.pattern }); |
| 182 | } |
| 183 | } catch (_) { |
| 184 | dispatch({ type: 'ERROR' }); |
| 185 | } |
| 186 | }; |
| 187 | |
| 188 | const search = async () => { |
| 189 | if (!fileSearch.current || state.pattern === null) { |
no test coverage detected