Skip to content

Commit 0dd14a1

Browse files
authored
fix(amazonq): duplicates in lsp getContextCommandPrompt aws#6756
There are two types of context shown in the context list: 1. the ones by explicit @ 2. the ones by @workspace 1) has relativePaths with start/end line being -1, 2) has relativePaths with non -1 start/end lines, 1) is doing dedupe with 2) but 1) also needs to dedupe itself
1 parent f712ae1 commit 0dd14a1

File tree

1 file changed

+3
-1
lines changed
  • packages/core/src/codewhispererChat/controllers/chat

1 file changed

+3
-1
lines changed

packages/core/src/codewhispererChat/controllers/chat/controller.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1104,12 +1104,14 @@ export class ChatController {
11041104
const relativePathsOfMergedRelevantDocuments = triggerPayload.documentReferences.map(
11051105
(doc) => doc.relativeFilePath
11061106
)
1107+
const seen: string[] = []
11071108
for (const relativePath of relativePathsOfContextCommandFiles) {
1108-
if (!relativePathsOfMergedRelevantDocuments.includes(relativePath)) {
1109+
if (!relativePathsOfMergedRelevantDocuments.includes(relativePath) && !seen.includes(relativePath)) {
11091110
triggerPayload.documentReferences.push({
11101111
relativeFilePath: relativePath,
11111112
lineRanges: [{ first: -1, second: -1 }],
11121113
})
1114+
seen.push(relativePath)
11131115
}
11141116
}
11151117
if (triggerPayload.documentReferences) {

0 commit comments

Comments
 (0)