Skip to content

Commit 889ba5b

Browse files
committed
fix: defensive check for local context controller instance and remove unreachable conditional
1 parent 98bdf87 commit 889ba5b

File tree

1 file changed

+7
-16
lines changed

1 file changed

+7
-16
lines changed

server/aws-lsp-codewhisperer/src/shared/supplementalContextUtil/crossFileContextUtil.ts

Lines changed: 7 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -72,21 +72,7 @@ export async function fetchSupplementalContextForSrc(
7272
if (supplementalContextConfig === undefined) {
7373
return supplementalContextConfig
7474
}
75-
76-
if (supplementalContextConfig === 'OpenTabs_BM25') {
77-
const opentabsContextPromise = waitUntil(
78-
async function () {
79-
return await fetchOpenTabsContext(document, position, workspace, cancellationToken)
80-
},
81-
{ timeout: supplementalContextTimeoutInMs, interval: 5, truthy: false }
82-
)
83-
const supContext = (await opentabsContextPromise) ?? []
84-
return {
85-
supplementalContextItems: supContext,
86-
strategy: supContext.length === 0 ? 'Empty' : 'OpenTabs_BM25',
87-
}
88-
}
89-
75+
//TODO: add logic for other strategies once available
9076
if (supplementalContextConfig === 'codemap') {
9177
return await codemapContext(document, position, workspace, cancellationToken)
9278
}
@@ -151,13 +137,18 @@ export async function fetchProjectContext(
151137
): Promise<CodeWhispererSupplementalContextItem[]> {
152138
const inputChunk: Chunk = getInputChunk(document, position, crossFileContextConfig.numberOfLinesEachChunk)
153139
const fsPath = URI.parse(document.uri).fsPath
140+
let controller: LocalProjectContextController
154141
const inlineProjectContextRequest: QueryInlineProjectContextRequestV2 = {
155142
query: inputChunk.content,
156143
filePath: fsPath,
157144
target,
158145
}
159146

160-
const controller = LocalProjectContextController.getInstance()
147+
try {
148+
controller = LocalProjectContextController.getInstance()
149+
} catch (e) {
150+
return []
151+
}
161152
return controller.queryInlineProjectContext(inlineProjectContextRequest)
162153
}
163154

0 commit comments

Comments
 (0)