From 0dd14a114829e63a18c63c4704381fb3bec221de Mon Sep 17 00:00:00 2001 From: andrewyuq <89420755+andrewyuq@users.noreply.github.com> Date: Mon, 10 Mar 2025 12:27:17 -0700 Subject: [PATCH] fix(amazonq): duplicates in lsp getContextCommandPrompt #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 --- .../core/src/codewhispererChat/controllers/chat/controller.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/packages/core/src/codewhispererChat/controllers/chat/controller.ts b/packages/core/src/codewhispererChat/controllers/chat/controller.ts index c2d8bb5fd5..e1a41d69a2 100644 --- a/packages/core/src/codewhispererChat/controllers/chat/controller.ts +++ b/packages/core/src/codewhispererChat/controllers/chat/controller.ts @@ -1104,12 +1104,14 @@ export class ChatController { const relativePathsOfMergedRelevantDocuments = triggerPayload.documentReferences.map( (doc) => doc.relativeFilePath ) + const seen: string[] = [] for (const relativePath of relativePathsOfContextCommandFiles) { - if (!relativePathsOfMergedRelevantDocuments.includes(relativePath)) { + if (!relativePathsOfMergedRelevantDocuments.includes(relativePath) && !seen.includes(relativePath)) { triggerPayload.documentReferences.push({ relativeFilePath: relativePath, lineRanges: [{ first: -1, second: -1 }], }) + seen.push(relativePath) } } if (triggerPayload.documentReferences) {