Skip to content

Commit ad48623

Browse files
committed
fix(amazonq): remove duplicates from lsp getContextCommandPrompt
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 997b3b7 commit ad48623

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
@@ -1103,12 +1103,14 @@ export class ChatController {
11031103
const relativePathsOfMergedRelevantDocuments = triggerPayload.documentReferences.map(
11041104
(doc) => doc.relativeFilePath
11051105
)
1106+
const seen: string[] = []
11061107
for (const relativePath of relativePathsOfContextCommandFiles) {
1107-
if (!relativePathsOfMergedRelevantDocuments.includes(relativePath)) {
1108+
if (!relativePathsOfMergedRelevantDocuments.includes(relativePath) && !seen.includes(relativePath)) {
11081109
triggerPayload.documentReferences.push({
11091110
relativeFilePath: relativePath,
11101111
lineRanges: [{ first: -1, second: -1 }],
11111112
})
1113+
seen.push(relativePath)
11121114
}
11131115
}
11141116
if (triggerPayload.documentReferences) {

0 commit comments

Comments
 (0)