Skip to content

Commit 9b8b9f4

Browse files
committed
fix(code-index): search and initialize the task workspace
Resolve the search manager from the task workspace rather than the active editor. Initialize unready managers before feature checks and add focused unit and workspace regression coverage.
1 parent a0f2e03 commit 9b8b9f4

3 files changed

Lines changed: 728 additions & 3 deletions

File tree

‎src/core/tools/CodebaseSearchTool.ts‎

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,17 +52,23 @@ export class CodebaseSearchTool extends BaseTool<"codebase_search"> {
5252
task.consecutiveMistakeCount = 0
5353

5454
try {
55-
const context = task.providerRef.deref()?.context
56-
if (!context) {
55+
const provider = task.providerRef.deref()
56+
const context = provider?.context
57+
if (!provider || !context) {
5758
throw new Error("Extension context is not available.")
5859
}
5960

60-
const manager = CodeIndexManagerRegistry.getOrCreate(context)
61+
const manager = CodeIndexManagerRegistry.getOrCreate(context, workspacePath)
6162

6263
if (!manager) {
6364
throw new Error("CodeIndexManager is not available.")
6465
}
6566

67+
// Task paths outside the activation workspace list may have a newly created manager.
68+
if (!manager.isInitialized) {
69+
await manager.initialize(provider.contextProxy)
70+
}
71+
6672
if (!manager.isFeatureEnabled) {
6773
throw new Error("Code Indexing is disabled in the settings.")
6874
}

0 commit comments

Comments
 (0)