@@ -8,14 +8,15 @@ import { FeatureConfigProvider, fs } from '../../../shared'
88import path = require( 'path' )
99import { BM25Document , BM25Okapi } from './rankBm25'
1010import { ToolkitError } from '../../../shared/errors'
11- import { crossFileContextConfig , supplemetalContextFetchingTimeoutMsg } from '../../models/constants'
11+ import { crossFileContextConfig , supplementalContextTimeoutInMs , supplemetalContextFetchingTimeoutMsg } from '../../models/constants'
1212import { CancellationError } from '../../../shared/utilities/timeoutUtils'
1313import { isTestFile } from './codeParsingUtil'
1414import { getFileDistance } from '../../../shared/filesystemUtilities'
1515import { getOpenFilesInWindow } from '../../../shared/utilities/editorUtilities'
1616import { getLogger } from '../../../shared/logger/logger'
1717import { CodeWhispererSupplementalContext , CodeWhispererSupplementalContextItem } from '../../models/model'
1818import { LspController } from '../../../amazonq/lsp/lspController'
19+ import { asyncCallWithTimeout } from '../commonUtil'
1920
2021type CrossFileSupportedLanguage =
2122 | 'java'
@@ -63,7 +64,7 @@ export async function fetchSupplementalContextForSrc(
6364 return fetchSupplementalContextForSrcV1 ( editor , cancellationToken )
6465 }
6566 try {
66- return fetchSupplementalContextForSrcV2 ( editor )
67+ return asyncCallWithTimeout ( fetchSupplementalContextForSrcV2 ( editor ) , "time out when fetching supplemental context" , supplementalContextTimeoutInMs )
6768 } catch ( e ) {
6869 getLogger ( ) . error ( `Failed to fetch supplemental context from LSP ${ e } ` )
6970 return fetchSupplementalContextForSrcV1 ( editor , cancellationToken )
@@ -78,11 +79,9 @@ export async function fetchSupplementalContextForSrcV2(
7879
7980 const inlineProjectContext : { content : string ; score : number ; filePath : string } [ ] =
8081 await LspController . instance . queryInlineProjectContext ( inputChunkContent . content , editor . document . uri . fsPath )
81- getLogger ( ) . info ( JSON . stringify ( inlineProjectContext ) )
8282
83- const supContextItems : CodeWhispererSupplementalContextItem [ ] = [ ]
8483 return {
85- supplementalContextItems : [ ...supContextItems ] ,
84+ supplementalContextItems : [ ...inlineProjectContext ] ,
8685 strategy : 'LSP' ,
8786 }
8887}
@@ -188,7 +187,7 @@ function getSupplementalContextConfig(languageId: vscode.TextDocument['languageI
188187 if ( FeatureConfigProvider . instance . isNewProjectContextGroup ( ) ) {
189188 return 'v2'
190189 }
191- return 'v1 '
190+ return 'v2 '
192191}
193192
194193/**
0 commit comments