(input: string, options?: { force?: boolean })
| 165 | } |
| 166 | |
| 167 | const load = (input: string, options?: { force?: boolean }) => { |
| 168 | const file = path.normalize(input) |
| 169 | if (!file) return Promise.resolve() |
| 170 | |
| 171 | const directory = scope() |
| 172 | const key = `${directory}\n${file}` |
| 173 | ensure(file) |
| 174 | |
| 175 | const current = store.file[file] |
| 176 | if (!options?.force && current?.loaded) return Promise.resolve() |
| 177 | |
| 178 | const pending = inflight.get(key) |
| 179 | if (pending) return pending |
| 180 | |
| 181 | setLoading(file) |
| 182 | |
| 183 | const promise = sdk() |
| 184 | .client.file.read({ path: file }) |
| 185 | .then((x) => { |
| 186 | if (scope() !== directory) return |
| 187 | const content = x.data |
| 188 | setLoaded(file, content) |
| 189 | |
| 190 | if (!content) return |
| 191 | touchFileContent(file, approxBytes(content)) |
| 192 | evictContent(new Set([file])) |
| 193 | }) |
| 194 | .catch((e) => { |
| 195 | if (scope() !== directory) return |
| 196 | setLoadError(file, errorMessage(e, language.t("error.chain.unknown"))) |
| 197 | }) |
| 198 | .finally(() => { |
| 199 | inflight.delete(key) |
| 200 | }) |
| 201 | |
| 202 | inflight.set(key, promise) |
| 203 | return promise |
| 204 | } |
| 205 | |
| 206 | const search = (query: string, dirs: "true" | "false") => |
| 207 | sdk() |
no test coverage detected