Skip to content

Commit 8bd66cc

Browse files
authored
Revert "fix(amazonq): update cross file context config" (#4961)
* Revert "fix(amazonq): update cross file context config #4922" This reverts commit e6d9b50. * revert cross file config change
1 parent 199d0fa commit 8bd66cc

File tree

3 files changed

+16
-23
lines changed

3 files changed

+16
-23
lines changed
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"type": "Bug Fix",
3+
"description": "Completion may fail unexpected if user opened many tabs"
4+
}

packages/core/src/codewhisperer/models/constants.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -611,9 +611,9 @@ export const codeFixAppliedFailedMessage = 'Failed to apply suggested code fix.'
611611
export const runSecurityScanButtonTitle = 'Run security scan'
612612

613613
export const crossFileContextConfig = {
614-
numberOfChunkToFetch: 200,
615-
topK: 10,
616-
numberOfLinesEachChunk: 50,
614+
numberOfChunkToFetch: 60,
615+
topK: 3,
616+
numberOfLinesEachChunk: 10,
617617
}
618618

619619
export const utgConfig = {

packages/core/src/test/codewhisperer/util/crossFileContextUtil.test.ts

Lines changed: 9 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -38,30 +38,19 @@ describe('crossFileContextUtil', function () {
3838
tempFolder = (await createTestWorkspaceFolder()).uri.fsPath
3939
})
4040

41-
describe('should fetch 10 chunks and each chunk should contains 50 lines', function () {
41+
describe('should fetch 3 chunks and each chunk should contains 10 lines', function () {
4242
async function assertCorrectCodeChunk() {
43-
await openATextEditorWithText(sampleFileOf60Lines.repeat(10), 'CrossFile.java', tempFolder, {
44-
preview: false,
45-
})
43+
await openATextEditorWithText(sampleFileOf60Lines, 'CrossFile.java', tempFolder, { preview: false })
4644
const myCurrentEditor = await openATextEditorWithText('', 'TargetFile.java', tempFolder, {
4745
preview: false,
4846
})
4947
const actual = await crossFile.fetchSupplementalContextForSrc(myCurrentEditor, fakeCancellationToken)
5048
assert.ok(actual)
51-
assert.ok(actual.supplementalContextItems.length === crossFileContextConfig.topK)
52-
53-
assert.strictEqual(
54-
actual.supplementalContextItems[0].content.split('\n').length,
55-
crossFileContextConfig.numberOfLinesEachChunk
56-
)
57-
assert.strictEqual(
58-
actual.supplementalContextItems[1].content.split('\n').length,
59-
crossFileContextConfig.numberOfLinesEachChunk
60-
)
61-
assert.strictEqual(
62-
actual.supplementalContextItems[2].content.split('\n').length,
63-
crossFileContextConfig.numberOfLinesEachChunk
64-
)
49+
assert.ok(actual.supplementalContextItems.length === 3)
50+
51+
assert.strictEqual(actual.supplementalContextItems[0].content.split('\n').length, 10)
52+
assert.strictEqual(actual.supplementalContextItems[1].content.split('\n').length, 10)
53+
assert.strictEqual(actual.supplementalContextItems[2].content.split('\n').length, 10)
6554
}
6655

6756
it('control group', async function () {
@@ -278,12 +267,12 @@ describe('crossFileContextUtil', function () {
278267
assert.strictEqual(chunks[1].content, 'line_6\nline_7')
279268
})
280269

281-
it('codewhisperer crossfile config should use 50 lines', async function () {
270+
it('codewhisperer crossfile config should use 10 lines', async function () {
282271
const filePath = path.join(tempFolder, 'file.txt')
283272
await toFile(sampleFileOf60Lines, filePath)
284273

285274
const chunks = await crossFile.splitFileToChunks(filePath, crossFileContextConfig.numberOfLinesEachChunk)
286-
assert.strictEqual(chunks.length, 2)
275+
assert.strictEqual(chunks.length, 6)
287276
})
288277
})
289278
})

0 commit comments

Comments
 (0)