Skip to content

Commit d816c0f

Browse files
committed
patch
1 parent ae2dce9 commit d816c0f

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

plugins/amazonq/codewhisperer/jetbrains-community/src/software/aws/toolkits/jetbrains/services/codewhisperer/util/CodeWhispererFileContextProvider.kt

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -325,14 +325,16 @@ class DefaultCodeWhispererFileContextProvider(private val project: Project) : Fi
325325
else -> SupplementalContextInfo.emptyCrossFileContextInfo(targetContext.filename)
326326
}
327327

328-
var c = contextBeforeTruncation.contents
328+
return truncateContext(contextBeforeTruncation)
329+
}
330+
331+
fun truncateContext(context: SupplementalContextInfo): SupplementalContextInfo {
332+
var c = context.contents
329333
while (c.sumOf { it.content.length } >= CodeWhispererConstants.CrossFile.MAX_TOTAL_LENGTH) {
330334
c = c.dropLast(1)
331335
}
332336

333-
val contextAfterTruncation = contextBeforeTruncation.copy(contents = c)
334-
335-
return contextAfterTruncation
337+
return context.copy(contents = c)
336338
}
337339

338340
@VisibleForTesting

0 commit comments

Comments
 (0)