| ... | ... | @@ -365,6 +365,7 @@ export const make = Effect.fn("WorkspaceSearchIndex.make")(function* ( |
| 365 | 365 | catch: (cause) => new WorkspaceSearchIndexDestroyFailed({ cwd, cause }), |
| 366 | 366 | }).pipe(Effect.orDie), |
| 367 | 367 | ); |
| 368 | let initialScanTimedOut = false; |
| 368 | 369 | yield* waitForIndexReady( |
| 369 | 370 | cwd, |
| 370 | 371 | finder, |
| ... | ... | @@ -374,8 +375,18 @@ export const make = Effect.fn("WorkspaceSearchIndex.make")(function* ( |
| 374 | 375 | reason, |
| 375 | 376 | cause, |
| 376 | 377 | }), |
| 378 | ).pipe( |
| 379 | Effect.catchTag("WorkspaceSearchIndexScanTimedOut", (error) => |
| 380 | variant === "paths" |
| 381 | ? Effect.sync(() => { |
| 382 | initialScanTimedOut = true; |
| 383 | }) |
| 384 | : Effect.fail(error), |
| 385 | ), |
| 377 | 386 | ); |
| 378 | 387 | |
| 388 | const hasIncompleteInitialScan = () => initialScanTimedOut && finder.isScanning(); |
| 389 | |
| 379 | 390 | const runSearch = Effect.fn("WorkspaceSearchIndex.runSearch")(function* <A>( |
| 380 | 391 | query: string, |
| 381 | 392 | pageSize: number, |
| ... | ... | @@ -436,6 +447,7 @@ export const make = Effect.fn("WorkspaceSearchIndex.make")(function* ( |
| 436 | 447 | |
| 437 | 448 | const list: WorkspaceSearchIndex["Service"]["list"] = Effect.fn("WorkspaceSearchIndex.list")( |
| 438 | 449 | function* () { |
| 450 | const incompleteBeforeQuery = hasIncompleteInitialScan(); |
| 439 | 451 | const result = yield* runSearch("", WORKSPACE_INDEX_PAGE_SIZE, "mixedSearch", () => |
| 440 | 452 | finder.mixedSearch("", { pageSize: WORKSPACE_INDEX_PAGE_SIZE }), |
| 441 | 453 | ); |
| ... | ... | @@ -446,7 +458,8 @@ export const make = Effect.fn("WorkspaceSearchIndex.make")(function* ( |
| 446 | 458 | const entries = sortedEntries.slice(0, WORKSPACE_INDEX_MAX_ENTRIES); |
| 447 | 459 | return { |
| 448 | 460 | entries, |
| 449 | | truncated: mapped.truncated || entries.length < sortedEntries.length, |
| 461 | truncated: |
| 462 | incompleteBeforeQuery || mapped.truncated || entries.length < sortedEntries.length, |
| 450 | 463 | }; |
| 451 | 464 | }, |
| 452 | 465 | ); |
| ... | ... | @@ -455,22 +468,26 @@ export const make = Effect.fn("WorkspaceSearchIndex.make")(function* ( |
| 455 | 468 | "WorkspaceSearchIndex.search", |
| 456 | 469 | )(function* (query, limit, kind, imageOnly) { |
| 457 | 470 | const pageSize = imageOnly ? WORKSPACE_INDEX_PAGE_SIZE : Math.max(1, limit + 1); |
| 471 | const incompleteBeforeQuery = hasIncompleteInitialScan(); |
| 458 | 472 | if (kind === "file" || imageOnly) { |
| 459 | 473 | const result = yield* runSearch(query, pageSize, "fileSearch", () => |
| 460 | 474 | finder.fileSearch(query, { pageSize }), |
| 461 | 475 | ); |
| 462 | | return mapFileSearchResult(result, limit, imageOnly); |
| 476 | const mapped = mapFileSearchResult(result, limit, imageOnly); |
| 477 | return { ...mapped, truncated: incompleteBeforeQuery || mapped.truncated }; |
| 463 | 478 | } |
| 464 | 479 | if (kind === "directory") { |
| 465 | 480 | const result = yield* runSearch(query, pageSize, "directorySearch", () => |
| 466 | 481 | finder.directorySearch(query, { pageSize }), |
| 467 | 482 | ); |
| 468 | | return mapDirectorySearchResult(result, limit); |
| 483 | const mapped = mapDirectorySearchResult(result, limit); |
| 484 | return { ...mapped, truncated: incompleteBeforeQuery || mapped.truncated }; |
| 469 | 485 | } |
| 470 | 486 | const result = yield* runSearch(query, pageSize, "mixedSearch", () => |
| 471 | 487 | finder.mixedSearch(query, { pageSize }), |
| 472 | 488 | ); |
| 473 | | return mapMixedSearchResult(result, limit); |
| 489 | const mapped = mapMixedSearchResult(result, limit); |
| 490 | return { ...mapped, truncated: incompleteBeforeQuery || mapped.truncated }; |
| 474 | 491 | }); |
| 475 | 492 | |
| 476 | 493 | const searchContents: WorkspaceSearchIndex["Service"]["searchContents"] = Effect.fn( |