Skip to content

Commit

Permalink
fix(amazonq): duplicates in lsp getContextCommandPrompt #6756
Browse files Browse the repository at this point in the history
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
  • Loading branch information
andrewyuq authored Mar 10, 2025
1 parent f712ae1 commit 0dd14a1
Showing 1 changed file with 3 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit 0dd14a1

Please sign in to comment.