File tree Expand file tree Collapse file tree 1 file changed +10
-1
lines changed
server/aws-lsp-codewhisperer/src/shared/supplementalContextUtil Expand file tree Collapse file tree 1 file changed +10
-1
lines changed Original file line number Diff line number Diff line change @@ -209,8 +209,17 @@ export async function fetchOpenTabsContext(
209209 } )
210210 }
211211
212+ // Dedupe code chunks based on their filePath + content unique key
213+ const seen = new Set < string > ( )
214+ const deduped = supplementalContexts . filter ( item => {
215+ const key = `${ item . filePath } :${ item . content } `
216+ if ( seen . has ( key ) ) return false
217+ seen . add ( key )
218+ return true
219+ } )
220+
212221 // DO NOT send code chunk with empty content
213- return supplementalContexts . filter ( item => item . content . trim ( ) . length !== 0 )
222+ return deduped . filter ( item => item . content . trim ( ) . length !== 0 )
214223}
215224
216225function findBestKChunkMatches ( chunkInput : Chunk , chunkReferences : Chunk [ ] , k : number ) : Chunk [ ] {
You can’t perform that action at this time.
0 commit comments